DeepSpeed icon indicating copy to clipboard operation
DeepSpeed copied to clipboard

CUDA_HOME does not exist, unable to compile CUDA op(s)

Open macabdul9 opened this issue 3 years ago • 19 comments

ds_report:


-------------------------------------------------
DeepSpeed C++/CUDA extension op report
--------------------------------------------------
NOTE: Ops not installed will be just-in-time (JIT) compiled at
      runtime if needed. Op compatibility means that your system
      meet the required dependencies to JIT install the op.
--------------------------------------------------
JIT compiled ops requires ninja
ninja .................. [OKAY]
--------------------------------------------------
op name ................ installed .. compatible
--------------------------------------------------
cpu_adam ............... [NO] ....... [OKAY]
cpu_adagrad ............ [NO] ....... [OKAY]
fused_adam ............. [NO] ....... [OKAY]
fused_lamb ............. [NO] ....... [OKAY]
 [WARNING]  using untested triton version (1.1.1), only 1.0.0 is known to be compatible
sparse_attn ............ [NO] ....... [NO]
transformer ............ [NO] ....... [OKAY]
stochastic_transformer . [NO] ....... [OKAY]
async_io ............... [NO] ....... [OKAY]
utils .................. [NO] ....... [OKAY]
quantizer .............. [NO] ....... [OKAY]
Traceback (most recent call last):
  File "/home/awaheed/venv/bin/ds_report", line 6, in <module>
    cli_main()
  File "/home/awaheed/venv/lib/python3.8/site-packages/deepspeed/env_report.py", line 135, in cli_main
    main(hide_operator_status=args.hide_operator_status,
  File "/home/awaheed/venv/lib/python3.8/site-packages/deepspeed/env_report.py", line 129, in main
    op_report(verbose=not hide_errors_and_warnings)
  File "/home/awaheed/venv/lib/python3.8/site-packages/deepspeed/env_report.py", line 46, in op_report
    is_compatible = OKAY if builder.is_compatible(verbose) else no
  File "/home/awaheed/venv/lib/python3.8/site-packages/deepspeed/ops/op_builder/transformer_inference.py", line 25, in is_compatible
    sys_cuda_major, _ = installed_cuda_version()
  File "/home/awaheed/venv/lib/python3.8/site-packages/deepspeed/ops/op_builder/builder.py", line 40, in installed_cuda_version
    assert cuda_home is not None, "CUDA_HOME does not exist, unable to compile CUDA op(s)"
AssertionError: CUDA_HOME does not exist, unable to compile CUDA op(s)

Other Details

Platform: Linux PyTorch: 1.13.1 Transformers: 4.26.0

Note: CUDA works fine with PyTorch Screenshot from 2023-01-31 17-52-18

Similar issues were opened earlier but no solution:

  • https://github.com/microsoft/DeepSpeed/issues/2406
  • https://github.com/microsoft/DeepSpeed/issues/2337

CC @eltonzheng @jeffra @RezaYazdaniAminabadi @tjruwase @ShadenSmith

macabdul9 avatar Jan 31 '23 13:01 macabdul9

Hello @macabdul9

The most common reason for this is the missing CUDA Compiler. Running Pytorch with CUDA successfully means you have the CUDA Runtime. CUDA Runtime and CUDA Compiler are different components. Could you try the following commands and see if there is error?

nvcc --version
which nvcc

If there is error, then your CUDA Compiler is missing and you need to install it by installing the CUDA Toolkit from NVIDIA. Please note that the installed CUDA Compiler should have the same version as torch.version.cuda.

HeyangQin avatar Jan 31 '23 19:01 HeyangQin

Thanks, @HeyangQin. I got it fixed by loading the suitable CUDA compiler. Closing the issue.

macabdul9 avatar Feb 03 '23 04:02 macabdul9

Thanks!

TahaBinhuraib avatar Feb 07 '23 09:02 TahaBinhuraib

查看conda环境中的cuda版本 conda list | grep cuda

➜ export CUDA_HOME=/usr/local/cuda-11.2 #your cuda installed path ➜ pip install deepspeed

bolongliu avatar Apr 12 '23 05:04 bolongliu

Hello @macabdul9

The most common reason for this is the missing CUDA Compiler. Running Pytorch with CUDA successfully means you have the CUDA Runtime. CUDA Runtime and CUDA Compiler are different components. Could you try the following commands and see if there is error?

nvcc --version
which nvcc

If there is error, then your CUDA Compiler is missing and you need to install it by installing the CUDA Toolkit from NVIDIA. Please note that the installed CUDA Compiler should have the same version as torch.version.cuda.

How to installed CUDA Compiler by conda?

skye95git avatar Aug 22 '23 06:08 skye95git

export CUDA_HOME=/usr/local/cuda-11.2 #your cuda installed path

export CUDA_HOME=/usr/local/cuda-11.2 #your cuda installed path Is this path in the conda environment?

skye95git avatar Aug 22 '23 06:08 skye95git

Hello @macabdul9 The most common reason for this is the missing CUDA Compiler. Running Pytorch with CUDA successfully means you have the CUDA Runtime. CUDA Runtime and CUDA Compiler are different components. Could you try the following commands and see if there is error?

nvcc --version
which nvcc

If there is error, then your CUDA Compiler is missing and you need to install it by installing the CUDA Toolkit from NVIDIA. Please note that the installed CUDA Compiler should have the same version as torch.version.cuda.

How to installed CUDA Compiler by conda?

By using conda, you can try conda install -c nvidia cuda-compiler

celi52 avatar Oct 23 '23 20:10 celi52

Hello @macabdul9

The most common reason for this is the missing CUDA Compiler. Running Pytorch with CUDA successfully means you have the CUDA Runtime. CUDA Runtime and CUDA Compiler are different components. Could you try the following commands and see if there is error?

nvcc --version
which nvcc

If there is error, then your CUDA Compiler is missing and you need to install it by installing the CUDA Toolkit from NVIDIA. Please note that the installed CUDA Compiler should have the same version as torch.version.cuda.

大佬,牛逼 1700760784182

CCodeInspect avatar Nov 23 '23 17:11 CCodeInspect

Hello @macabdul9 The most common reason for this is the missing CUDA Compiler. Running Pytorch with CUDA successfully means you have the CUDA Runtime. CUDA Runtime and CUDA Compiler are different components. Could you try the following commands and see if there is error?

nvcc --version
which nvcc

If there is error, then your CUDA Compiler is missing and you need to install it by installing the CUDA Toolkit from NVIDIA. Please note that the installed CUDA Compiler should have the same version as torch.version.cuda.

How to installed CUDA Compiler by conda?

By using conda, you can try conda install -c nvidia cuda-compiler

thx a lot~

callanwu avatar Nov 29 '23 07:11 callanwu

Hello @macabdul9 The most common reason for this is the missing CUDA Compiler. Running Pytorch with CUDA successfully means you have the CUDA Runtime. CUDA Runtime and CUDA Compiler are different components. Could you try the following commands and see if there is error?

nvcc --version
which nvcc

If there is error, then your CUDA Compiler is missing and you need to install it by installing the CUDA Toolkit from NVIDIA. Please note that the installed CUDA Compiler should have the same version as torch.version.cuda.

How to installed CUDA Compiler by conda?

By using conda, you can try conda install -c nvidia cuda-compiler

thx a lot~

alterego238 avatar Dec 01 '23 08:12 alterego238

@HeyangQin

it works for me!!! thanks


nvcc --version
>> Command 'nvcc' not found, but can be installed with:
apt install nvidia-cuda-toolkit
which nvcc
>> /usr/bin/nvcc
export CUDA_HOME=/usr/
pip install  deepspeed==0.14.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

jiaohuix avatar Apr 09 '24 17:04 jiaohuix

Hello @macabdul9 The most common reason for this is the missing CUDA Compiler. Running Pytorch with CUDA successfully means you have the CUDA Runtime. CUDA Runtime and CUDA Compiler are different components. Could you try the following commands and see if there is error?

nvcc --version
which nvcc

If there is error, then your CUDA Compiler is missing and you need to install it by installing the CUDA Toolkit from NVIDIA. Please note that the installed CUDA Compiler should have the same version as torch.version.cuda.

How to installed CUDA Compiler by conda?

By using conda, you can try conda install -c nvidia cuda-compiler

When I'm trying with this comnad, I can only install the latest version even the version is specified. What should I do? The command I'm trying with is here conda install -c nvidia cuda-compiler==11.7.0

ipanseikamisama avatar Jun 04 '24 15:06 ipanseikamisama

Hello @macabdul9 The most common reason for this is the missing CUDA Compiler. Running Pytorch with CUDA successfully means you have the CUDA Runtime. CUDA Runtime and CUDA Compiler are different components. Could you try the following commands and see if there is error?

nvcc --version
which nvcc

If there is error, then your CUDA Compiler is missing and you need to install it by installing the CUDA Toolkit from NVIDIA. Please note that the installed CUDA Compiler should have the same version as torch.version.cuda.

How to installed CUDA Compiler by conda?

By using conda, you can try conda install -c nvidia cuda-compiler

@ipanseikamisama To spesify the version, I refer to this https://github.com/TimDettmers/bitsandbytes/issues/212, where cudatoolkit is installed, including the nvcc and other libs for dev. The version can be spesified by setting the version of the tool kit.

conda install -c "nvidia/label/cuda-11.8.0" cuda-toolkit

But if you have installed newest version through the above approach, the packages should be uninstalled before the right version of tool kit can be installed. Otherwise, there will be two versions of some cuda kits being installed.

I suspect that the version confliction is a bug, caused by the wrong dependency relationship provided by the packages or resolved by the conda.

46319943 avatar Jun 06 '24 08:06 46319943

Hello @macabdul9 The most common reason for this is the missing CUDA Compiler. Running Pytorch with CUDA successfully means you have the CUDA Runtime. CUDA Runtime and CUDA Compiler are different components. Could you try the following commands and see if there is error?

nvcc --version
which nvcc

If there is error, then your CUDA Compiler is missing and you need to install it by installing the CUDA Toolkit from NVIDIA. Please note that the installed CUDA Compiler should have the same version as torch.version.cuda.

How to installed CUDA Compiler by conda?

By using conda, you can try conda install -c nvidia cuda-compiler

@ipanseikamisama To spesify the version, I refer to this TimDettmers/bitsandbytes#212, where cudatoolkit is installed, including the nvcc and other libs for dev. The version can be spesified by setting the version of the tool kit.

conda install -c "nvidia/label/cuda-11.8.0" cuda-toolkit

But if you have installed newest version through the above approach, the packages should be uninstalled before the right version of tool kit can be installed. Otherwise, there will be two versions of some cuda kits being installed.

I suspect that the version confliction is a bug, caused by the wrong dependency relationship provided by the packages or resolved by the conda.

For updated conda syntax and toolkit versions refer https://anaconda.org/nvidia/cuda-toolkit

For example

conda install nvidia/label/cuda-12.1.0::cuda-toolkit

MohitLamba94 avatar Jun 08 '24 10:06 MohitLamba94

I'm having the same issue but I want to use deepspeed INSIDE a docker container for another lib that uses it (XTTS from coquiai). I get the same CUDA_HOME error but don't have conda inside the container. Can anyone point me in the right direction? Thanks!

thiswillbeyourgithub avatar Sep 14 '24 18:09 thiswillbeyourgithub

@HeyangQin

it works for me!!! thanks

nvcc --version

Command 'nvcc' not found, but can be installed with: apt install nvidia-cuda-toolkit which nvcc /usr/bin/nvcc export CUDA_HOME=/usr/ pip install deepspeed==0.14.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

装上了但依然显示ds_report bash: ds_report: command not found

lanhong123 avatar Nov 06 '24 10:11 lanhong123

Hello @macabdul9 The most common reason for this is the missing CUDA Compiler. Running Pytorch with CUDA successfully means you have the CUDA Runtime. CUDA Runtime and CUDA Compiler are different components. Could you try the following commands and see if there is error?

nvcc --version
which nvcc

If there is error, then your CUDA Compiler is missing and you need to install it by installing the CUDA Toolkit from NVIDIA. Please note that the installed CUDA Compiler should have the same version as torch.version.cuda.

How to installed CUDA Compiler by conda?

By using conda, you can try conda install -c nvidia cuda-compiler

@ipanseikamisama To spesify the version, I refer to this bitsandbytes-foundation/bitsandbytes#212, where cudatoolkit is installed, including the nvcc and other libs for dev. The version can be spesified by setting the version of the tool kit.

conda install -c "nvidia/label/cuda-11.8.0" cuda-toolkit

But if you have installed newest version through the above approach, the packages should be uninstalled before the right version of tool kit can be installed. Otherwise, there will be two versions of some cuda kits being installed.

I suspect that the version confliction is a bug, caused by the wrong dependency relationship provided by the packages or resolved by the conda.

I resolve my questions by installing cudatookit when conda create the venv, an example is

conda crreate -n myenv cudatoolkit=11.3 cudnn

Though I still didn't figure out how to install a cuda compiler in an already created conda environment, I find the solution above worked. But you can only install specific cuda version and may meet some conflicts when a cuda is already installed in your computer and is working. I resolved the conflicts by removing cuda from the system variables. In my case, I use the command.

unset LD_LIBRARY_PATH

I hope my experience can help.

ipanseikamisama avatar Nov 07 '24 10:11 ipanseikamisama

我使用的平台是一个没有网的服务器(Centos),我使用pip install --no-index --find-links=./packages来安装包的,还有别的解决方法吗(不使用conda 命令)? The platform I'm using is a server(Centos) with no network ,I use “pip install --no-index --find-links=. /packages ”to install packages. Is there another solution(Not using the conda command)?

goy-jin avatar Nov 26 '24 07:11 goy-jin

This solution works In my cluster, "CUDA_HOME not exists" only happen in version 0.16.4 with 2-nodes training when I training in only 1 node, 0.16.4 is work when I downgrade deepspeed to 0.11.0, this error disappear

@HeyangQin

it works for me!!! thanks

nvcc --version

Command 'nvcc' not found, but can be installed with: apt install nvidia-cuda-toolkit which nvcc /usr/bin/nvcc export CUDA_HOME=/usr/ pip install deepspeed==0.14.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

bio-punk avatar Feb 27 '25 03:02 bio-punk