CUDA_HOME does not exist, unable to compile CUDA op(s)
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

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
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.
Thanks, @HeyangQin. I got it fixed by loading the suitable CUDA compiler. Closing the issue.
Thanks!
查看conda环境中的cuda版本 conda list | grep cuda
➜ export CUDA_HOME=/usr/local/cuda-11.2 #your cuda installed path ➜ pip install deepspeed
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 nvccIf 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?
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?
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 nvccIf 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
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 nvccIf 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.
大佬,牛逼
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 nvccIf 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~
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 nvccIf 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~
@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
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 nvccIf 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
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 nvccIf 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.
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 nvccIf 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
cudatoolkitis 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-toolkitBut 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
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!
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
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 nvccIf 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
cudatoolkitis 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-toolkitBut 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.
我使用的平台是一个没有网的服务器(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)?
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
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