Using CUDA in ubuntu 22.04 for Julia

Hey everyone,

I am using ubuntu 22.04 and I am trying to use the GPU of my computer to train neural models using Flux. Here is the CUDA version I get using nvidia-smi :

±--------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.154.05 Driver Version: 535.154.05 CUDA Version: 12.2 |
|-----------------------------------------±---------------------±---------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+======================+======================|
| 0 NVIDIA T600 Laptop GPU Off | 00000000:01:00.0 Off | N/A |
| N/A 49C P0 7W / 35W | 5MiB / 4096MiB | 0% Default |
| | | N/A |
±----------------------------------------±---------------------±---------------------+

±--------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=======================================================================================|
| 0 N/A N/A 6010 G /usr/lib/xorg/Xorg 4MiB |
±--------------------------------------------------------------------------------------+

I have set the CUDA version in julia to match this :

using CUDA
CUDA.set_runtime_version!(v"12.2")

Yet after restarting julia, here is the message error I get :

using CUDA
┌ Error: CUDA.jl could not find an appropriate CUDA runtime to use.

│ This can have several reasons:
│ * you are using an unsupported platform: this version of CUDA.jl
│ only supports Linux (x86_64, aarch64, ppc64le) and Windows (x86_64),
│ while your platform was identified as x86_64-linux-gnu-libgfortran5-cxx11-libstdcxx30-cuda+none-julia_version+1.10.0;
│ * you precompiled CUDA.jl in an environment where the CUDA driver
│ was not available (i.e., a container, or an HPC login node).
│ in that case, you need to specify which CUDA version to use
│ by calling CUDA.set_runtime_version!;
│ * you requested use of a local CUDA toolkit, but not all
│ required components were discovered. try running with
│ JULIA_DEBUG=all in your environment for more details.

│ For more details, refer to the CUDA.jl documentation at
Overview · CUDA.jl
└ @ CUDA ~/.julia/packages/CUDA/35NC6/src/initialization.jl:82

It seems that Julia doesn’t like the CUDA 12.2 version. What can I do to make this work?

Thank you so much for your answers.

As far as I know you do not need to install any Nvidia CUDA toolkit if you want to use Nvidia graphic cards with Julia. Just install CUDA, don’t set any runtime version, it should just work…

You might have to uninstall any Nvidia toolkit you installed manually.

The recommended way to use CUDA.jl is to let it automatically download an 
appropriate CUDA toolkit. CUDA.jl will check your driver's capabilities, which 
versions of CUDA are available for your platform, and automatically download an 
appropriate artifact containing all the libraries that CUDA.jl supports.

To correct the first version of this message: You need to install the NVidia driver
before installing CUDA.jl, but NOT the toolkit.

This indicates that the NVIDIA driver was not found; CUDA 12.2 is normally supported just fine. Try pre-compiling CUDA and its dependencies again (e.g. by removing ~/.julia/compiled/*/CUDA* – we should probably make this more convenient) with JULIA_DEBUG=all set in your environment.