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

Apple Slicon安装报错 #30

Open
lorihuang opened this issue Feb 26, 2025 · 7 comments
Open

Apple Slicon安装报错 #30

lorihuang opened this issue Feb 26, 2025 · 7 comments

Comments

@lorihuang
Copy link

使用pip 安装requirement时安装报以下错误:
"""
Collecting flash_attn (from -r requirements.txt (line 14))
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/11/34/9bf60e736ed7bbe15055ac2dab48ec67d9dbd088d2b4ae318fd77190ab4e/flash_attn-2.7.4.post1.tar.gz (6.0 MB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [21 lines of output]
/private/var/folders/3p/tghlrh9d7zj9dkjyzdvgn5q40000gn/T/pip-install-nf6ja0in/flash-attn_333cffdeee0440208480fc31b281af97/setup.py:106: UserWarning: flash_attn was requested, but nvcc was not found. Are you sure your environment has nvcc available? If you're installing within a container from https://hub.docker.com/r/pytorch/pytorch, only images whose names contain 'devel' will provide nvcc.
warnings.warn(
Traceback (most recent call last):
File "", line 2, in
File "", line 34, in
File "/private/var/folders/3p/tghlrh9d7zj9dkjyzdvgn5q40000gn/T/pip-install-nf6ja0in/flash-attn_333cffdeee0440208480fc31b281af97/setup.py", line 198, in
CUDAExtension(
File "/Users//miniconda3/envs/multi/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 1130, in CUDAExtension
library_dirs += library_paths(device_type="cuda")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/
/miniconda3/envs/multi/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 1264, in library_paths
if (not os.path.exists(_join_cuda_home(lib_dir)) and
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/*/miniconda3/envs/multi/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 2525, 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.

  torch.__version__  = 2.6.0
  
  
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
"""
请问是否是因为不支持苹果Slicon所导致的?如果是,有办法解决这个问题吗?谢谢!

@lorihuang lorihuang changed the title Apple Slicon安装包错 Apple Slicon安装报错 Feb 26, 2025
@JackChius
Copy link

类似问题,老是安装requirements.txt这一步报错,我的是win
Image

@Vargol
Copy link

Vargol commented Feb 26, 2025

The code as is doesn't work on MacOS & Apple Silicon, there's a fair few hard coded CUDA references, and they use float64 in their ROPE implementation.

I've hacked my copy of the code so that the T2V 1.3B model will run to completion (with a reduced number of steps, as at 81 it hits a MPS memory limitation) but the denoising returns a tensor full of NaN's.

@Runtrons
Copy link

@Vargol I'll help contribute if you send your progress so far.

@Vargol
Copy link

Vargol commented Feb 26, 2025

mps_changes.txt

I've attached the changes I made, they're not pretty basically changing hard coded CUDA references to hard coded MPS, and float64 to float32. I've only looked into T2V as I haven't got the RAM for the bigger model.

Ran with...

python generate.py  --task t2v-1.3B --size 832*480 --ckpt_dir ./Wan2.1-T2V-1.3B  --sample_shift 8 --sample_guide_scale 6 --prompt "a man walks over a pit of tortilla chips." --frame_num=4 --offload_model=False --sample_solver=dpm++

sample_solver parameter used as unipc still requires export PYTORCH_ENABLE_MPS_FALLBACK=1 to be set

The lower number of frames to keep the memory usage down, and run quickly for testing.
The NaN's are coming out of the denoise, I ran with a print on xo before decoding to check.

@bakhti-ai
Copy link

Hi there, I forked and adjusted the repo to make it work on my macbook m1 pro. After adjustments it worked on macos. I opened a PR for this original repo as well. You can check it out here #69

@HighDoping
Copy link

I forked @bakhti-uzb version and add some breaking changes for Apple Silicon to reduce memory usage. The model can run with only 32GB of RAM, althought with fewer frames.

@Runtrons
Copy link

@HighDoping Thanks! Giving it a go now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants