Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root. #4

Closed
Charlie-Steer opened this issue Mar 15, 2024 · 1 comment
Assignees
Labels
help wanted Extra attention is needed

Comments

@Charlie-Steer
Copy link

Upon running ComfyUI I'm getting this error: "OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root."

This is on Linux Mint, but I got the same issue when trying previously on Windows 10. I tried reinstalling the python "torch" module, as it seems to be responsible for installing CUDA if I'm not mistaken. I tried installing torch with both commands provided in the ComfyUI repo for both stable and nightly, but none fixed the issue:

pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu121

pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu121

Error Log:

Traceback (most recent call last):
  File "/home/charlie/projects/ComfyUI/nodes.py", line 1888, in load_custom_node
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/charlie/projects/ComfyUI/custom_nodes/human-parser-comfyui-node/__init__.py", line 1, in <module>
    from .HumanParserLIPCustomNode import HumanParserLIPCustomNode
  File "/home/charlie/projects/ComfyUI/custom_nodes/human-parser-comfyui-node/HumanParserLIPCustomNode.py", line 5, in <module>
    from .utils import generate
  File "/home/charlie/projects/ComfyUI/custom_nodes/human-parser-comfyui-node/utils.py", line 8, in <module>
    from .schp import networks
  File "/home/charlie/projects/ComfyUI/custom_nodes/human-parser-comfyui-node/schp/networks/__init__.py", line 3, in <module>
    from .AugmentCE2P import resnet101
  File "/home/charlie/projects/ComfyUI/custom_nodes/human-parser-comfyui-node/schp/networks/AugmentCE2P.py", line 21, in <module>
    from ..modules import InPlaceABNSync
  File "/home/charlie/projects/ComfyUI/custom_nodes/human-parser-comfyui-node/schp/modules/__init__.py", line 1, in <module>
    from .bn import ABN, InPlaceABN, InPlaceABNSync
  File "/home/charlie/projects/ComfyUI/custom_nodes/human-parser-comfyui-node/schp/modules/bn.py", line 10, in <module>
    from .functions import *
  File "/home/charlie/projects/ComfyUI/custom_nodes/human-parser-comfyui-node/schp/modules/functions.py", line 12, in <module>
    _backend = load(name="inplace_abn",
  File "/home/charlie/projects/ComfyUI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1309, in load
    return _jit_compile(
  File "/home/charlie/projects/ComfyUI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1719, in _jit_compile
    _write_ninja_file_and_build_library(
  File "/home/charlie/projects/ComfyUI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1809, in _write_ninja_file_and_build_library
    extra_ldflags = _prepare_ldflags(
  File "/home/charlie/projects/ComfyUI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1901, in _prepare_ldflags
    if (not os.path.exists(_join_cuda_home(extra_lib_dir)) and
  File "/home/charlie/projects/ComfyUI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 2419, in _join_cuda_home
    raise OSError('CUDA_HOME environment variable is not set. '
OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.

Cannot import /home/charlie/projects/ComfyUI/custom_nodes/human-parser-comfyui-node module for custom nodes: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.

It only seems an issue with this particular node:

Import times for custom nodes:
   0.0 seconds: /home/charlie/projects/ComfyUI/custom_nodes/image-resize-comfyui
   0.0 seconds: /home/charlie/projects/ComfyUI/custom_nodes/ComfyUI_IPAdapter_plus
   0.0 seconds: /home/charlie/projects/ComfyUI/custom_nodes/cozy-sal-vton
   0.0 seconds: /home/charlie/projects/ComfyUI/custom_nodes/rgthree-comfy
   0.0 seconds: /home/charlie/projects/ComfyUI/custom_nodes/ComfyUI_essentials
   0.4 seconds: /home/charlie/projects/ComfyUI/custom_nodes/ComfyUI-Impact-Pack
   0.4 seconds (IMPORT FAILED): /home/charlie/projects/ComfyUI/custom_nodes/human-parser-comfyui-node
   1.0 seconds: /home/charlie/projects/ComfyUI/custom_nodes/was-node-suite-comfyui
@gabidobo gabidobo self-assigned this Apr 2, 2024
@gabidobo gabidobo added the help wanted Extra attention is needed label Apr 2, 2024
@gabidobo
Copy link
Member

gabidobo commented Apr 2, 2024

Ok so for some reason the CUDA_HOME env var isn't set by the cuda install process in your scenario, but it is required for loading CPP extensions like our node does.

I think this thread might clear some things up: conda/conda#7757

It's a simple case of pointing the CUDA_HOME var to your CUDA homedir, but I'm not really sure where that is for you.

I'd also check if cudatoolkit is installed, and try installing it if not.

@gabidobo gabidobo closed this as completed Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants