github上clone任何仓库都得创建虚拟环境
我这台电脑的显卡是4070 ti super, 一般python=3.9(首选) 或者3.10
1.nvidia-smi 查看自己的电脑能支持的最大CUDA Version 。我是13.1,一般下11.8就可以。
C:\Users\shine>nvidia-smi Thu Apr 30 13:39:20 2026 +-----------------------------------------------------------------------------------------+ | NVIDIA-SMI 591.86 Driver Version: 591.86 CUDA Version: 13.1 | +-----------------------------------------+------------------------+----------------------+ | GPU Name Driver-Model | Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |=========================================+========================+======================| | 0 NVIDIA GeForce RTX 4070 ... WDDM | 00000000:01:00.0 On | N/A | | 0% 43C P8 9W / 285W | 729MiB / 16376MiB | 5% Default | | | | N/A | +-----------------------------------------+------------------------+----------------------+ +-----------------------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=========================================================================================| | 0 N/A N/A 3008 C+G ...yb3d8bbwe\WindowsTerminal.exe N/A | | 0 N/A N/A 4436 C+G ...crosoft\OneDrive\OneDrive.exe N/A | | 0 N/A N/A 6032 C+G ...5n1h2txyewy\TextInputHost.exe N/A | | 0 N/A N/A 7460 C+G ...em32\ApplicationFrameHost.exe N/A | | 0 N/A N/A 8040 C+G ...y\StartMenuExperienceHost.exe N/A | | 0 N/A N/A 12408 C+G ....0.3912.86\msedgewebview2.exe N/A | | 0 N/A N/A 18624 C+G ...64__8wekyb3d8bbwe\GameBar.exe N/A | | 0 N/A N/A 21464 C+G ...ntrolPanel\SystemSettings.exe N/A | | 0 N/A N/A 23668 C+G ...8wekyb3d8bbwe\M365Copilot.exe N/A | | 0 N/A N/A 24100 C+G ..._cw5n1h2txyewy\SearchHost.exe N/A | | 0 N/A N/A 24172 C+G ....0.3912.86\msedgewebview2.exe N/A | | 0 N/A N/A 25196 C+G C:\Windows\explorer.exe N/A | | 0 N/A N/A 25732 C+G ...indows\System32\ShellHost.exe N/A | | 0 N/A N/A 26284 C+G ...2txyewy\CrossDeviceResume.exe N/A | | 0 N/A N/A 26344 C+G ...xyewy\ShellExperienceHost.exe N/A | | 0 N/A N/A 26812 C+G ....0.3912.86\msedgewebview2.exe N/A | | 0 N/A N/A 27444 C+G ...t\Edge\Application\msedge.exe N/A | +-----------------------------------------------------------------------------------------+torch-2.0.1+cu118-cp39-cp39-win_amd64.whl
C:\Users\shine>conda create -n depth_anything_v2 python=3.9 -yC:\Users\shine>conda activate depth_anything_v2切换到项目目录下
(depth_anything_v2) PS E:\Projects\Depth-Anything-V2-main> pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118核心的两个包:
Downloading https://download-r2.pytorch.org/whl/cu118/torch-2.7.1%2Bcu118-cp39-cp39-win_amd64.whl (2817.1 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.8/2.8 GB 6.1 MB/s 0:06:14 Downloading https://download-r2.pytorch.org/whl/cu118/torchvision-0.22.1%2Bcu118-cp39-cp39-win_amd64.whl (5.5 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.5/5.5 MB 7.1 MB/s 0:00:00自己可以先下好,电脑和u盘存一份。python版本和torch torchvision版本比较固定,需要时拷过去,再建新环境很快。
前提是你确定nvidia CUDA版本>=11.8。python版本和torch torchvision版本不变。
https://download-r2.pytorch.org/whl/cu118/torch-2.7.1%2Bcu118-cp39-cp39-win_amd64.whlhttps://download-r2.pytorch.org/whl/cu118/torchvision-0.22.1%2Bcu118-cp39-cp39-win_amd64.whl