It looks like nvcc --version is pointing to the system-installed CUDA version (12.6), while your Conda environment may not have a CUDA toolkit installed. Additionally, if LD_LIBRARY_PATH shows nothing, it could indicate that the Conda environment isn’t managing any CUDA-related libraries.
Here’s a step-by-step approach to resolve this and ensure that your Conda environment has a properly installed and configured CUDA toolkit:
If conda list doesn’t show any installed CUDA toolkit, it means that CUDA was not installed in the current environment. You can install the required CUDA version in your Conda environment by running:
conda install cudatoolkit=<version>
For example, if you want to install CUDA 11.7, you would run:
conda install cudatoolkit=11.7
Make sure the installed version matches the one compatible with your driver and PyTorch/TensorFlow, or other CUDA-dependent libraries.
After installation, verify it is installed in the Conda environment:
You should see something like:
# Name Version Build Channel
cudatoolkit 11.7.0 h3eacb3f_0
This confirms that the correct CUDA toolkit version is installed in the environment.
If LD_LIBRARY_PATH is not set, you may need to configure it manually or let Conda do it for you. Normally, Conda environments should automatically set this when activated, but in case it’s missing, you can manually update it.
To set LD_LIBRARY_PATH correctly, you can use the following command:
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH
This adds the Conda environment’s library folder to LD_LIBRARY_PATH, making sure your application uses the correct CUDA libraries.
You can also check the current value of LD_LIBRARY_PATH:
It should point to paths like /home/user/miniconda3/envs/myenv/lib.
After activating the Conda environment and setting LD_LIBRARY_PATH, you can check whether the environment is using the correct CUDA toolkit:
This command should show a path within the Conda environment, like:
/home/user/miniconda3/envs/myenv/bin/nvcc
If it shows a system path like /usr/local/cuda/bin/nvcc, that means the system CUDA version is being used.
If you are using a deep learning framework like PyTorch or TensorFlow, you can verify which CUDA version they are using by running:
For PyTorch:
print(torch.version.cuda)
For TensorFlow:
print(tf.sysconfig.get_build_info()['cuda_version'])
This ensures that your deep learning framework is correctly using the CUDA version from the Conda environment.
If you want to avoid conflicts with the system-wide CUDA version (12.6 in your case), you can either:
- Uninstall the system CUDA: If you don’t need it system-wide, consider uninstalling it.
- Avoid modifying global environment variables: Ensure that system CUDA paths are not set in your
.bashrc or .bash_profile.
By installing the CUDA toolkit in your Conda environment and ensuring that the LD_LIBRARY_PATH and nvcc point to the Conda environment, you should be able to avoid conflicts with the system-wide CUDA installation.