hiyouga / LLaMA-Factory

Unify Efficient Fine-Tuning of 100+ LLMs
Apache License 2.0
25.26k stars 3.13k forks source link

fix torch-npu dependency #4561

Closed hashstone closed 1 day ago

hashstone commented 2 days ago

What does this PR do?

Fix torch-npu dependency problem like this

#0 11.87 Collecting triton==2.1.0 (from torch==2.1.0->llamafactory==0.8.3.dev0)
#0 11.90   Downloading triton-2.1.0-0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.metadata (1.3 kB)
#0 11.90 INFO: pip is looking at multiple versions of torch-npu to determine which version is compatible with other requirements. This could take a while.
#0 11.90 ERROR: Cannot install llamafactory and llamafactory[metrics,torch-npu]==0.8.3.dev0 because these package versions have conflicting dependencies.
#0 11.90 
#0 11.90 The conflict is caused by:
#0 11.90     llamafactory[metrics,torch-npu] 0.8.3.dev0 depends on torch==2.1.0; extra == "torch-npu"
#0 11.90     torch-npu 2.1.0.post3 depends on torch==2.1.0+cpu
#0 11.90 
#0 11.90 To fix this you could try to:
#0 11.90 1. loosen the range of package versions you've specified
#0 11.90 2. remove package versions to allow pip to attempt to solve the dependency conflict
#0 11.90 
#0 11.90 ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

Before submitting

hiyouga commented 2 days ago

cc @MengqingCao

MengqingCao commented 2 days ago

@hashstone Thanks for the fix! But the installation of torch-npu differs by architecture. Maybe adding a dependency "torch-npu-x86" in setup.py and choosing to install "torch-npu" or "torch-npu-x86" depending on the architecture in the Dockerfile is a solution. @hiyouga What do you think? image https://pypi.org/project/torch-npu/2.1.0.post3/

hashstone commented 2 days ago

@MengqingCao have modified as your proposal, please review.

hiyouga commented 1 day ago

Hi @hashstone , if possible, could you please help us verify whether the problem has been fixed or not, using the current version: https://github.com/hiyouga/LLaMA-Factory/blob/main/docker/docker-npu/Dockerfile ? thanks!

hashstone commented 1 day ago

Hi @hashstone , if possible, could you please help us verify whether the problem has been fixed or not, using the current version: https://github.com/hiyouga/LLaMA-Factory/blob/main/docker/docker-npu/Dockerfile ? thanks!

In my local build env, cross building through docker build --platform linux/arm64 or docker build --platform linux/amd64 is pass.

hiyouga commented 15 hours ago

Hi @hashstone , if possible, could you please help us verify whether the problem has been fixed or not, using the current version: https://github.com/hiyouga/LLaMA-Factory/blob/main/docker/docker-npu/Dockerfile ? thanks!

In my local build env, cross building through docker build --platform linux/arm64 or docker build --platform linux/amd64 is pass.

Great news, thanks for the verification