Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

cublas error with "--math-mode=fast" #510

Closed
kbarros opened this issue Nov 25, 2019 · 1 comment
Closed

cublas error with "--math-mode=fast" #510

kbarros opened this issue Nov 25, 2019 · 1 comment
Labels

Comments

@kbarros
Copy link

kbarros commented Nov 25, 2019

From the terminal:

$ julia --math-mode=fast

(v1.1) pkg> status
    Status `~/.julia/environments/v1.1/Project.toml`
  [c5f51814] CUDAdrv v4.0.4
  [be33ccc6] CUDAnative v2.5.5
  [3a865a2d] CuArrays v1.4.7
  [...]

using CuArrays
CuArrays.CUBLAS.handle()

gives me this error:

ERROR: MethodError: Cannot `convert` an object of type Ptr{Nothing} to an object of type CuArrays.CUBLAS.cublasMath_t
...

The simple fix is to reorder arguments in this line:
cublasSetMathMode(handle, CUBLAS_TENSOR_OP_MATH)

However, the existence of this error seems to indicate that nobody is relying on the behavior that "fast-math" mode enables CUBLAS_TENSOR_OP_MATH. I would suggest making the "fast-math" independent of CUBLAS_TENSOR_OP_MATH by deleting the highlighted code here:
https://github.com/JuliaGPU/CuArrays.jl/blob/master/src/blas/CUBLAS.jl#L55-L59

If the user wants CUBLAS_TENSOR_OP_MATH, then they really want it, and they can make that explicit by calling:
cublasSetMathMode(handle(), CUBLAS_TENSOR_OP_MATH)

@maleadt
Copy link
Member

maleadt commented Jan 21, 2020

Sorry this took so long. Fixed in #567. I think leaving that code in makes sense, since it conforms to other changes when running under fast math mode. Downstream users can still set the mode explicitly if they want to (cc @MikeInnes, maybe Flux wants to).

maleadt added a commit that referenced this issue Jan 21, 2020
Fix CUBLAS math mode under fast math (#510).
@maleadt maleadt closed this as completed Jan 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants