I am getting an error when building CuArrays

#1

I have installed CUDA 9.0 toolkit and Xcode and i have exported to PATH but when i build CuArrays i get this error:

  Building SpecialFunctions → `~/.julia/packages/SpecialFunctions/fvheQ/deps/build.log`
  Building CUDAdrv ─────────→ `~/.julia/packages/CUDAdrv/lu32K/deps/build.log`
┌ Error: Error building `CUDAdrv`: 
│ Initializing CUDA driver failed with code 3..
└ @ Pkg.Operations /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Operations.jl:1075
  Building LLVM ────────────→ `~/.julia/packages/LLVM/tg8MX/deps/build.log`
  Building CUDAnative ──────→ `~/.julia/packages/CUDAnative/PFgO3/deps/build.log`
┌ Error: Error building `CUDAnative`: 
│ Dependent package CUDAdrv.jl has not been built successfully.
│ 
│ This is not a fatal error, but GPU functionality will be unavailable.
│ If you expected this to work, please open a thread on
│ https://discourse.julialang.org/c/domain/gpu
└ @ Pkg.Operations /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Operations.jl:1075
  Building Conda ───────────→ `~/.julia/packages/Conda/CpuvI/deps/build.log`
  Building FFTW ────────────→ `~/.julia/packages/FFTW/p7sLQ/deps/build.log`
  Building CuArrays ────────→ `~/.julia/packages/CuArrays/qZCAt/deps/build.log`
┌ Error: Error building `CuArrays`: 
│ Dependent package CUDAdrv.jl has not been built successfully
└ @ Pkg.Operations /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Operations.jl:1075```
#2

Do you have the drivers installed? I believe the CUDA drivers are a separate install from the toolkit.

#3

Yes i have cuda drivers 418 installed and cuda toolkit 9.2 with the patch

#4

Copying from Slack (best not to post in multiple places):

it doesn’t make much sense that calling cuInit would return CUDA_ERROR_NOT_INITIALIZED (error 3)…
the NVIDIA docs also don’t specify that this error could ever be thrown.
do you have multiple libcudas in your system? if so, could you try running with JULIA_DEBUG=CUDAapi, find out which libcuda it detects (it’s in the output), and see if that library is the correct one?

#5

Sorry, total n00b to julia here. How do i run with JULIA_DEBUG=CUDAapi?

also i only have CUDA 9.2 installed as far as i know

#6

Specify it as an environment variable, eg. in your command prompt: JULIA_DEBUG=CUDAapi julia

#7

ah got it. i installed CUDA toolkit 10.1. one problem was my environmental variable wasnt set to the cuda install directory. still doesnt build properly after fixing that however. here is the output:

(v1.1) pkg> build CuArrays
  Building SpecialFunctions → `~/.julia/packages/SpecialFunctions/fvheQ/deps/build.log`
  Building CUDAdrv ─────────→ `~/.julia/packages/CUDAdrv/lu32K/deps/build.log`
┌ Error: Error building `CUDAdrv`: 
│ ┌ Debug: Request to look for binary nvcc
│ │   locations = 0-element Array{String,1}
│ └ @ CUDAapi ~/.julia/packages/CUDAapi/0Ozyy/src/CUDAapi.jl:8
│ ┌ Debug: Looking for binary nvcc
│ │   locations =
│ │    8-element Array{String,1}:
│ │     "/Users/Galen/.cargo/bin"        
│ │     "/Developer/NVIDIA/CUDA-10.1/bin"
│ │     "/usr/local/bin"                 
│ │     "/usr/bin"                       
│ │     "/bin"                           
│ │     "/usr/sbin"                      
│ │     "/sbin"                          
│ │     "/Library/TeX/texbin"            
│ └ @ CUDAapi ~/.julia/packages/CUDAapi/0Ozyy/src/CUDAapi.jl:8
│ ┌ Debug: Found binary nvcc at /Developer/NVIDIA/CUDA-10.1/bin
│ └ @ CUDAapi ~/.julia/packages/CUDAapi/0Ozyy/src/discovery.jl:142
│ ┌ Debug: Looking for CUDA toolkit via nvcc binary
│ │   path = "/Developer/NVIDIA/CUDA-10.1/bin/nvcc"
│ │   dir = "/Developer/NVIDIA/CUDA-10.1"
│ └ @ CUDAapi ~/.julia/packages/CUDAapi/0Ozyy/src/CUDAapi.jl:8
│ ┌ Debug: Request to look for library cudart
│ │   locations = 0-element Array{String,1}
│ └ @ CUDAapi ~/.julia/packages/CUDAapi/0Ozyy/src/CUDAapi.jl:8
│ ┌ Debug: Looking for library libcudart.dylib, libcudart.dylib.10, libcudart.dylib.10.1, libcudart.dylib.10.0, libcudart.dylib.9, libcudart.dylib.9.2, libcudart.dylib.9.1, libcudart.dylib.9.0, libcudart.dylib.8, libcudart.dylib.8.0, libcudart.dylib.7, libcudart.dylib.7.5, libcudart.dylib.7.0, libcudart.dylib.6, libcudart.dylib.6.5, libcudart.dylib.6.0, libcudart.dylib.5, libcudart.dylib.5.5, libcudart.dylib.5.0, libcudart.dylib.4, libcudart.dylib.4.2, libcudart.dylib.4.1, libcudart.dylib.4.0, libcudart.dylib.3, libcudart.dylib.3.2, libcudart.dylib.3.1, libcudart.dylib.3.0, libcudart.dylib.2, libcudart.dylib.2.2, libcudart.dylib.2.1, libcudart.dylib.2.0, libcudart.dylib.1, libcudart.dylib.1.1, libcudart.dylib.1.0
│ │   locations = 0-element Array{String,1}
│ └ @ CUDAapi ~/.julia/packages/CUDAapi/0Ozyy/src/CUDAapi.jl:8
│ ┌ Debug: Found library libcudart.dylib at /Developer/NVIDIA/CUDA-10.1/lib/libcudart.dylib
│ └ @ CUDAapi ~/.julia/packages/CUDAapi/0Ozyy/src/discovery.jl:91
│ ┌ Debug: Looking for CUDA toolkit via CUDA runtime library
│ │   path = "/Developer/NVIDIA/CUDA-10.1/lib/libcudart.dylib"
│ │   dir = "/Developer/NVIDIA/CUDA-10.1"
│ └ @ CUDAapi ~/.julia/packages/CUDAapi/0Ozyy/src/CUDAapi.jl:8
│ ┌ Debug: Looking for CUDA toolkit via default installation directories
│ │   dirs =
│ │    1-element Array{Any,1}:
│ │     "/usr/local/cuda"
│ └ @ CUDAapi ~/.julia/packages/CUDAapi/0Ozyy/src/CUDAapi.jl:8
│ ┌ Debug: Found CUDA toolkit at /Developer/NVIDIA/CUDA-10.1, /usr/local/cuda
│ └ @ CUDAapi ~/.julia/packages/CUDAapi/0Ozyy/src/discovery.jl:271
│ ┌ Debug: Request to look for library cuda
│ │   locations =
│ │    2-element Array{String,1}:
│ │     "/Developer/NVIDIA/CUDA-10.1"
│ │     "/usr/local/cuda"            
│ └ @ CUDAapi ~/.julia/packages/CUDAapi/0Ozyy/src/CUDAapi.jl:8
│ ┌ Debug: Looking for library libcuda.dylib, libcuda.dylib.10, libcuda.dylib.10.1, libcuda.dylib.10.0, libcuda.dylib.9, libcuda.dylib.9.2, libcuda.dylib.9.1, libcuda.dylib.9.0, libcuda.dylib.8, libcuda.dylib.8.0, libcuda.dylib.7, libcuda.dylib.7.5, libcuda.dylib.7.0, libcuda.dylib.6, libcuda.dylib.6.5, libcuda.dylib.6.0, libcuda.dylib.5, libcuda.dylib.5.5, libcuda.dylib.5.0, libcuda.dylib.4, libcuda.dylib.4.2, libcuda.dylib.4.1, libcuda.dylib.4.0, libcuda.dylib.3, libcuda.dylib.3.2, libcuda.dylib.3.1, libcuda.dylib.3.0, libcuda.dylib.2, libcuda.dylib.2.2, libcuda.dylib.2.1, libcuda.dylib.2.0, libcuda.dylib.1, libcuda.dylib.1.1, libcuda.dylib.1.0
│ │   locations =
│ │    6-element Array{String,1}:
│ │     "/Developer/NVIDIA/CUDA-10.1"      
│ │     "/Developer/NVIDIA/CUDA-10.1/lib"  
│ │     "/Developer/NVIDIA/CUDA-10.1/lib64"
│ │     "/usr/local/cuda"                  
│ │     "/usr/local/cuda/lib"              
│ │     "/usr/local/cuda/lib64"            
│ └ @ CUDAapi ~/.julia/packages/CUDAapi/0Ozyy/src/CUDAapi.jl:8
│ ┌ Debug: Found library /usr/local/cuda/lib/libcuda.dylib at /usr/local/cuda/lib/libcuda.dylib
│ └ @ CUDAapi ~/.julia/packages/CUDAapi/0Ozyy/src/discovery.jl:91
│ Initializing CUDA driver failed with code 3..
└ @ Pkg.Operations /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Operations.jl:1075
  Building LLVM ────────────→ `~/.julia/packages/LLVM/tg8MX/deps/build.log`
  Building CUDAnative ──────→ `~/.julia/packages/CUDAnative/PFgO3/deps/build.log`
┌ Error: Error building `CUDAnative`: 
│ Dependent package CUDAdrv.jl has not been built successfully.
│ 
│ This is not a fatal error, but GPU functionality will be unavailable.
│ If you expected this to work, please open a thread on
│ https://discourse.julialang.org/c/domain/gpu
└ @ Pkg.Operations /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Operations.jl:1075
  Building Conda ───────────→ `~/.julia/packages/Conda/CpuvI/deps/build.log`
  Building FFTW ────────────→ `~/.julia/packages/FFTW/p7sLQ/deps/build.log`
  Building CuArrays ────────→ `~/.julia/packages/CuArrays/qZCAt/deps/build.log`
┌ Error: Error building `CuArrays`: 
│ Dependent package CUDAdrv.jl has not been built successfully
└ @ Pkg.Operations /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Operations.jl:1075

#8

That shouldn’t be necessary. CUDAapi.jl should detect your CUDA installation.

I’m afraid I can’t help though. It looks like libcuda gets picked up correctly, but doesn’t initialize. Can you try the following:

julia -e 'using Libdl; @show ccall((:cuInit, "/usr/local/cuda/lib/libcuda.dylib"), Cint, (Cint,), 0)'

Can you also test whether CUDA C programs work (just try some GPU hello world)?