Geforce 50xx系顯卡最低支持cuda128,torch cu128 release版本目前還沒有釋放,所以自己基于2.6.0源碼自己編譯wheel包。
1.?前置條件
1. 使用visual studio installer 安裝visual studio 2022,工作負荷選擇【使用c++的桌面開發】,安裝完成后將“VC\Tools\MSVC\<版本號>\bin\Hostx64\x64”對應的路徑加入環境變量;
2. 訪問https://github.com/pytorch/pytorch/releases/download/v2.6.0/pytorch-v2.6.0.tar.gz下載源碼,可以替換成kkgithub鏡像訪問,下載后解壓;
3. 訪問https://github.com/conda-forge/miniforge/releases/download/24.11.3-0/Miniforge3-Windows-x86_64.exe安裝miniforge;
2. 編譯
打開 Miniforge Prompt,依次執行如下代碼:
##如果訪問報錯或速度緩慢,搜索并替換conda、pip清華源
conda create torch_build_env python=3.10 libuv
conda activate torch_build_env
conda install -y astunparse numpy ninja pyyaml setuptools cmake cffi typing_extensions future six requests dataclassesset MAX_JOBS=24
set USE_DISTRIBUTED=OFF
set USE_CUDA=ON
set PYTORCH_BUILD_VERSION=2.6.0a0+cu128-cp31016-win_x64
set PYTORCH_BUILD_NUMBER=0 cd C:\pytorch-v2.6.0
##執行前先確保刪除build目錄
python setup.py bdist_wheel
編譯完成后,wheel包在dist目錄下,使用pip安裝
pip install dist\torch-2.6.0a0+cu128.cp31016.win.x64-cp310-cp310-win_amd64.whl