{"id":281,"hash":"6a82f1208071e1cef5a23bb76e8f5a1e483f5e2662edd63a042c13a10159944d","pattern":"CUDA initialization: CUDA unknown error - this may be due to an incorrectly set up environment","full_message":"I am trying to install torch with CUDA support.\n\nHere is the result of my collect_env.py script:\n\nPyTorch version: 1.7.1+cu101\nIs debug build: False\nCUDA used to build PyTorch: 10.1\nROCM used to build PyTorch: N/A\n\nOS: Ubuntu 20.04.1 LTS (x86_64)\nGCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0\nClang version: Could not collect\nCMake version: Could not collect\n\nPython version: 3.9 (64-bit runtime)\nIs CUDA available: False\nCUDA runtime version: 10.1.243\nGPU models and configuration: GPU 0: GeForce GTX 1080\nNvidia driver version: 460.39\ncuDNN version: Could not collect\nHIP runtime version: N/A\nMIOpen runtime version: N/A\n\nVersions of relevant libraries:\n[pip3] numpy==1.19.2\n[pip3] torch==1.7.1+cu101\n[pip3] torchaudio==0.7.2\n[pip3] torchvision==0.8.2+cu101\n[conda] blas                      1.0                         mkl  \n[conda] cudatoolkit               10.1.243             h6bb024c_0  \n[conda] mkl                       2020.2                      256  \n[conda] mkl-service               2.3.0            py39he8ac12f_0  \n[conda] mkl_fft                   1.3.0            py39h54f3939_0  \n[conda] mkl_random                1.0.2            py39h63df603_0  \n[conda] numpy                     1.19.2           py39h89c1606_0  \n[conda] numpy-base                1.19.2           py39h2ae0177_0  \n[conda] torch                     1.7.1+cu101              pypi_0    pypi\n[conda] torchaudio                0.7.2                    pypi_0    pypi\n[conda] torchvision               0.8.2+cu101              pypi_0    pypi\n\nProcess finished with exit code 0\n\nHere is the output of nvcc - V\n\nnvcc: NVIDIA (R) Cuda compiler driver\nCopyright (c) 2005-2019 NVIDIA Corporation\nBuilt on Sun_Jul_28_19:07:16_PDT_2019\nCuda compilation tools, release 10.1, V10.1.243\n\nFinally, here is the output of nvidia-smi\n\n+-----------------------------------------------------------------------------+\n| NVIDIA-SMI 460.39       Driver Version: 460.39       CUDA Version: 11.2     |\n|-------------------------------+----------------------+----------------------+\n| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |\n| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |\n|                               |                      |               MIG M. |\n|===============================+======================+======================|\n|   0  GeForce GTX 1080    Off  | 00000000:01:00.0  On |                  N/A |\n|  0%   52C    P0    46W / 180W |    624MiB /  8116MiB |      0%      Default |\n|                               |                      |                  N/A |\n+-------------------------------+----------------------+----------------------+\n                                                                               \n+-----------------------------------------------------------------------------+\n| Processes:                                                                  |\n|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |\n|        ID   ID                                                   Usage      |\n|=============================================================================|\n|    0   N/A  N/A       873      G   /usr/lib/xorg/Xorg                101MiB |\n|    0   N/A  N/A      1407      G   /usr/lib/xorg/Xorg                419MiB |\n|    0   N/A  N/A      2029      G   ...AAAAAAAAA= --shared-files       90MiB |\n+-----------------------------------------------------------------------------+\n\nHowever, when I try to run\n\nprint(torch.cuda.is_available())\n\nI get the following error:\n\nUserWarning: CUDA initialization: CUDA unknown error - this may be due to an incorrectly set up environment, e.g. changing env variable CUDA_VISIBLE_DEVICES after program start. Setting the available devices to be zero. (Triggered internally at  /pytorch/c10/cuda/CUDAFunctions.cpp:100.)\n  return torch._C._cuda_getDeviceCount() > 0\n\nI have performed a reboot, and I have followed the post-installation steps as detailed in here","ecosystem":"pypi","package_name":"pytorch","package_version":null,"solution":"Had the same issue and in my case solution was very easy, however it wasn't easy to find it. I had to remove and insert nvidia_uvm module. So:\n\n> sudo rmmod nvidia_uvm\n> sudo modprobe nvidia_uvm\n\nThat's all. Just before these command collect_env.py reported \"Is CUDA available: False\". After: \"Is CUDA available: True\"","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/66857471/cuda-initialization-cuda-unknown-error-this-may-be-due-to-an-incorrectly-set","votes":63,"created_at":"2026-04-19T04:41:44.172231+00:00","updated_at":"2026-04-19T04:51:56.203700+00:00"}