{"id":36244,"date":"2025-05-08T22:35:54","date_gmt":"2025-05-08T14:35:54","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/36244.html"},"modified":"2025-05-08T22:35:54","modified_gmt":"2025-05-08T14:35:54","slug":"%e6%9c%8d%e5%8a%a1%e5%99%a8%e4%b8%8a%e9%85%8d%e7%bd%aecuda%e3%80%81cudnn%e3%80%81anaconda%e5%92%8cpython%e7%8e%af%e5%a2%83%e7%9a%84%e5%ae%8c%e6%95%b4%e8%bf%87%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/36244.html","title":{"rendered":"\u670d\u52a1\u5668\u4e0a\u914d\u7f6eCUDA\u3001cuDNN\u3001Anaconda\u548cPython\u73af\u5883\u7684\u5b8c\u6574\u8fc7\u7a0b"},"content":{"rendered":"<p>\u5728\u6df1\u5ea6\u5b66\u4e60\u548c\u79d1\u5b66\u8ba1\u7b97\u9886\u57df&#xff0c;\u6b63\u786e\u914d\u7f6eGPU\u52a0\u901f\u73af\u5883\u5bf9\u4e8e\u63d0\u9ad8\u8ba1\u7b97\u6548\u7387\u81f3\u5173\u91cd\u8981\u3002\u6211\u8bb0\u5f55\u4e86\u5728\u670d\u52a1\u5668\u4e0a\u914d\u7f6eCUDA\u3001cuDNN\u3001Anaconda\u4ee5\u53ca\u76f8\u5e94\u7684Python\u73af\u5883\u7684\u8fc7\u7a0b\u3002<\/p>\n<h3>\u4e00\u3001\u51c6\u5907\u5de5\u4f5c<\/h3>\n<p>\u5728\u5f00\u59cb\u5b89\u88c5\u524d&#xff0c;\u9700\u8981\u786e\u8ba4\u670d\u52a1\u5668\u7684\u57fa\u672c\u914d\u7f6e&#xff1a;<\/p>\n<li>\u786e\u8ba4\u670d\u52a1\u5668\u4e0a\u5b89\u88c5\u4e86NVIDIA GPU<\/li>\n<li>\u68c0\u67e5GPU\u9a71\u52a8\u662f\u5426\u5df2\u5b89\u88c5<\/li>\n<li>\u786e\u8ba4\u670d\u52a1\u5668\u64cd\u4f5c\u7cfb\u7edf\u7248\u672c<\/li>\n<h4>\u68c0\u67e5GPU\u548c\u9a71\u52a8<\/h4>\n<p>nvidia-smi<\/p>\n<p>\u5982\u679c\u663e\u793aGPU\u4fe1\u606f&#xff0c;\u8bf4\u660e\u9a71\u52a8\u5df2\u6b63\u786e\u5b89\u88c5\u3002\u5982\u679c\u6ca1\u6709&#xff0c;\u9700\u8981\u5148\u5b89\u88c5NVIDIA\u9a71\u52a8\u3002<\/p>\n<h3>\u4e8c\u3001\u5b89\u88c5CUDA<\/h3>\n<p>CUDA\u662fNVIDIA\u63a8\u51fa\u7684\u5e76\u884c\u8ba1\u7b97\u5e73\u53f0\u548c\u7f16\u7a0b\u6a21\u578b&#xff0c;\u662f\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u4f7f\u7528GPU\u52a0\u901f\u7684\u57fa\u7840\u3002<\/p>\n<h4>1. \u4e0b\u8f7dCUDA\u5b89\u88c5\u5305<\/h4>\n<p>\u8bbf\u95eeNVIDIA\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u9002\u5408\u4f60\u7cfb\u7edf\u7684CUDA\u7248\u672c\u3002\u4ee5CUDA 11.7\u4e3a\u4f8b&#xff1a;<\/p>\n<p><span class=\"token function\">wget<\/span> https:\/\/developer.download.nvidia.com\/compute\/cuda\/11.7.0\/local_installers\/cuda_11.7.0_515.43.04_linux.run<\/p>\n<h4>2. \u5b89\u88c5CUDA<\/h4>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">sh<\/span> cuda_11.7.0_515.43.04_linux.run<\/p>\n<p>\u5b89\u88c5\u8fc7\u7a0b\u4e2d&#xff1a;<\/p>\n<ul>\n<li>\u63a5\u53d7\u8bb8\u53ef\u534f\u8bae<\/li>\n<li>\u5982\u679c\u5df2\u5b89\u88c5\u9a71\u52a8&#xff0c;\u53ef\u4ee5\u53d6\u6d88\u9009\u62e9\u9a71\u52a8\u5b89\u88c5<\/li>\n<li>\u9009\u62e9\u5b89\u88c5CUDA Toolkit\u548c\u76f8\u5173\u7ec4\u4ef6<\/li>\n<\/ul>\n<h4>3. \u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/h4>\n<p>\u7f16\u8f91~\/.bashrc\u6587\u4ef6&#xff1a;<\/p>\n<p><span class=\"token function\">nano<\/span> ~\/.bashrc<\/p>\n<p>\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9&#xff1a;<\/p>\n<p><span class=\"token builtin class-name\">export<\/span> <span class=\"token assign-left variable\"><span class=\"token environment constant\">PATH<\/span><\/span><span class=\"token operator\">&#061;<\/span>\/usr\/local\/cuda-11.7\/bin:<span class=\"token environment constant\">$PATH<\/span><br \/>\n<span class=\"token builtin class-name\">export<\/span> <span class=\"token assign-left variable\">LD_LIBRARY_PATH<\/span><span class=\"token operator\">&#061;<\/span>\/usr\/local\/cuda-11.7\/lib64:<span class=\"token variable\">$LD_LIBRARY_PATH<\/span><\/p>\n<p>\u4f7f\u73af\u5883\u53d8\u91cf\u751f\u6548&#xff1a;<\/p>\n<p><span class=\"token builtin class-name\">source<\/span> ~\/.bashrc<\/p>\n<h4>4. \u9a8c\u8bc1CUDA\u5b89\u88c5<\/h4>\n<p>nvcc &#8211;version<\/p>\n<p>\u5982\u679c\u663e\u793aCUDA\u7248\u672c\u4fe1\u606f&#xff0c;\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<h3>\u4e09\u3001\u5b89\u88c5cuDNN<\/h3>\n<p>cuDNN\u662fNVIDIA\u5f00\u53d1\u7684\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u5e93&#xff0c;\u53ef\u4ee5\u52a0\u901f\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u7684\u8ba1\u7b97\u3002<\/p>\n<h4>1. \u4e0b\u8f7dcuDNN<\/h4>\n<p>\u8bbf\u95eeNVIDIA cuDNN\u9875\u9762\u4e0b\u8f7d\u4e0eCUDA\u7248\u672c\u517c\u5bb9\u7684cuDNN&#xff08;\u9700\u8981\u6ce8\u518cNVIDIA\u5f00\u53d1\u8005\u8d26\u53f7&#xff09;\u3002<\/p>\n<h4>2. \u89e3\u538b\u5e76\u5b89\u88c5cuDNN<\/h4>\n<p><span class=\"token function\">tar<\/span> -xzvf cudnn-linux-x86_64-8.x.x.x_cudaX.Y-archive.tar.xz<br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">cp<\/span> cudnn-linux-x86_64-8.x.x.x_cudaX.Y-archive\/include\/cudnn*.h \/usr\/local\/cuda-11.7\/include<br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">cp<\/span> cudnn-linux-x86_64-8.x.x.x_cudaX.Y-archive\/lib\/libcudnn* \/usr\/local\/cuda-11.7\/lib64<br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">chmod<\/span> a&#043;r \/usr\/local\/cuda-11.7\/include\/cudnn*.h \/usr\/local\/cuda-11.7\/lib64\/libcudnn*<\/p>\n<h4>3. \u9a8c\u8bc1cuDNN\u5b89\u88c5<\/h4>\n<p><span class=\"token function\">cat<\/span> \/usr\/local\/cuda\/include\/cudnn_version.h <span class=\"token operator\">|<\/span> <span class=\"token function\">grep<\/span> CUDNN_MAJOR -A <span class=\"token number\">2<\/span><\/p>\n<h3>\u56db\u3001\u5b89\u88c5Anaconda<\/h3>\n<p>Anaconda\u662f\u4e00\u4e2a\u5f00\u6e90\u7684Python\u53d1\u884c\u7248&#xff0c;\u5305\u542b\u4e86conda\u3001Python\u7b49180\u591a\u4e2a\u79d1\u5b66\u5305\u53ca\u5176\u4f9d\u8d56\u9879\u3002<\/p>\n<p>\u5b98\u7f51\u4e0b\u8f7d\u5730\u5740&#xff1a;https:\/\/repo.anaconda.com\/archive\/<\/p>\n<p>\u4e0b\u8f7d\u5730\u5740&#xff1a;https:\/\/mirrors.tuna.tsinghua.edu.cn\/anaconda\/archive\/<\/p>\n<h4>1. \u4e0b\u8f7dAnaconda\u5b89\u88c5\u5305<\/h4>\n<p><span class=\"token function\">wget<\/span> https:\/\/repo.anaconda.com\/archive\/Anaconda3-2023.07-2-Linux-x86_64.sh<\/p>\n<h4>2. \u5b89\u88c5Anaconda<\/h4>\n<p><span class=\"token function\">bash<\/span> Anaconda3-2023.07-2-Linux-x86_64.sh<\/p>\n<p>\u6309\u7167\u63d0\u793a\u5b8c\u6210\u5b89\u88c5&#xff1a;<\/p>\n<ul>\n<li>\u63a5\u53d7\u8bb8\u53ef\u534f\u8bae<\/li>\n<li>\u786e\u8ba4\u5b89\u88c5\u4f4d\u7f6e<\/li>\n<li>\u662f\u5426\u521d\u59cb\u5316Anaconda&#xff08;\u5efa\u8bae\u9009\u62e9&#034;yes&#034;&#xff09;<\/li>\n<\/ul>\n<h4>3. \u6fc0\u6d3bAnaconda<\/h4>\n<p><span class=\"token builtin class-name\">source<\/span> ~\/.bashrc<\/p>\n<h4>4. \u9a8c\u8bc1Anaconda\u5b89\u88c5<\/h4>\n<p>conda &#8211;version<\/p>\n<h3>\u4e94\u3001\u521b\u5efa\u5e76\u914d\u7f6ePython\u73af\u5883<\/h3>\n<p>\u4f7f\u7528Anaconda\u53ef\u4ee5\u8f7b\u677e\u521b\u5efa\u548c\u7ba1\u7406\u4e0d\u540c\u7684Python\u73af\u5883\u3002<\/p>\n<h4>1. \u521b\u5efa\u65b0\u7684Python\u73af\u5883<\/h4>\n<p>conda create -n deeplearning <span class=\"token assign-left variable\">python<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">3.9<\/span><\/p>\n<h4>2. \u6fc0\u6d3b\u73af\u5883<\/h4>\n<p>conda activate deeplearning<\/p>\n<h3>\u516d\u3001\u5b89\u88c5PyTorch<\/h3>\n<p>PyTorch\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6&#xff0c;\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684GPU\u52a0\u901f\u529f\u80fd\u3002\u4ee5\u4e0b\u662f\u51e0\u79cd\u5b89\u88c5PyTorch\u7684\u65b9\u6cd5&#xff1a;<\/p>\n<h4>1. \u4f7f\u7528conda\u5b89\u88c5PyTorch&#xff08;\u63a8\u8350&#xff09;<\/h4>\n<p>\u6839\u636e\u4f60\u7684CUDA\u7248\u672c\u9009\u62e9\u5408\u9002\u7684PyTorch\u7248\u672c\u3002\u4ee5CUDA 11.7\u4e3a\u4f8b&#xff1a;<\/p>\n<p>conda <span class=\"token function\">install<\/span> pytorch torchvision torchaudio pytorch-cuda<span class=\"token operator\">&#061;<\/span><span class=\"token number\">11.7<\/span> -c pytorch -c nvidia<\/p>\n<p>\u5982\u679c\u4f60\u60f3\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684PyTorch&#xff0c;\u53ef\u4ee5\u6307\u5b9a\u7248\u672c\u53f7&#xff1a;<\/p>\n<p>conda <span class=\"token function\">install<\/span> <span class=\"token assign-left variable\">pytorch<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">1.13<\/span>.1 <span class=\"token assign-left variable\">torchvision<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">0.14<\/span>.1 <span class=\"token assign-left variable\">torchaudio<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">0.13<\/span>.1 pytorch-cuda<span class=\"token operator\">&#061;<\/span><span class=\"token number\">11.7<\/span> -c pytorch -c nvidia<\/p>\n<h4>2. \u4f7f\u7528pip\u5b89\u88c5PyTorch<\/h4>\n<p>\u4e5f\u53ef\u4ee5\u4f7f\u7528pip\u5b89\u88c5PyTorch&#xff1a;<\/p>\n<p>pip <span class=\"token function\">install<\/span> torch torchvision torchaudio &#8211;index-url https:\/\/download.pytorch.org\/whl\/cu117<\/p>\n<h4>3. \u4ece\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5&#xff08;\u9ad8\u7ea7\u7528\u6237&#xff09;<\/h4>\n<p>\u5982\u679c\u9700\u8981\u81ea\u5b9a\u4e49PyTorch\u529f\u80fd\u6216\u9488\u5bf9\u7279\u5b9a\u786c\u4ef6\u4f18\u5316&#xff0c;\u53ef\u4ee5\u4ece\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u514b\u9686PyTorch\u4ed3\u5e93<\/span><br \/>\n<span class=\"token function\">git<\/span> clone &#8211;recursive https:\/\/github.com\/pytorch\/pytorch<br \/>\n<span class=\"token builtin class-name\">cd<\/span> pytorch<\/p>\n<p><span class=\"token comment\"># \u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/span><br \/>\n<span class=\"token builtin class-name\">export<\/span> <span class=\"token assign-left variable\">CMAKE_PREFIX_PATH<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token variable\">${CONDA_PREFIX<span class=\"token operator\">:-<\/span>&#034;$(dirname $(which conda))<span class=\"token operator\">\/<\/span>..<span class=\"token operator\">\/<\/span>&#034;}<\/span><br \/>\n<span class=\"token builtin class-name\">export<\/span> <span class=\"token assign-left variable\">CUDA_HOME<\/span><span class=\"token operator\">&#061;<\/span>\/usr\/local\/cuda-11.7<\/p>\n<p><span class=\"token comment\"># \u5b89\u88c5\u4f9d\u8d56<\/span><br \/>\nconda <span class=\"token function\">install<\/span> -y astunparse numpy ninja pyyaml setuptools cmake cffi typing_extensions future six requests dataclasses<\/p>\n<p><span class=\"token comment\"># \u7f16\u8bd1\u5b89\u88c5<\/span><br \/>\npython setup.py <span class=\"token function\">install<\/span><\/p>\n<h4>4. \u9a8c\u8bc1PyTorch\u5b89\u88c5<\/h4>\n<p>\u5728Python\u73af\u5883\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u4ee3\u7801\u9a8c\u8bc1PyTorch\u662f\u5426\u6b63\u786e\u5b89\u88c5\u5e76\u80fd\u591f\u4f7f\u7528GPU&#xff1a;<\/p>\n<p><span class=\"token keyword\">import<\/span> torch<br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;PyTorch\u7248\u672c:&#034;<\/span><span class=\"token punctuation\">,<\/span> torch<span class=\"token punctuation\">.<\/span>__version__<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;CUDA\u662f\u5426\u53ef\u7528:&#034;<\/span><span class=\"token punctuation\">,<\/span> torch<span class=\"token punctuation\">.<\/span>cuda<span class=\"token punctuation\">.<\/span>is_available<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;CUDA\u7248\u672c:&#034;<\/span><span class=\"token punctuation\">,<\/span> torch<span class=\"token punctuation\">.<\/span>version<span class=\"token punctuation\">.<\/span>cuda<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;cuDNN\u7248\u672c:&#034;<\/span><span class=\"token punctuation\">,<\/span> torch<span class=\"token punctuation\">.<\/span>backends<span class=\"token punctuation\">.<\/span>cudnn<span class=\"token punctuation\">.<\/span>version<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;GPU\u6570\u91cf:&#034;<\/span><span class=\"token punctuation\">,<\/span> torch<span class=\"token punctuation\">.<\/span>cuda<span class=\"token punctuation\">.<\/span>device_count<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u5f53\u524dGPU:&#034;<\/span><span class=\"token punctuation\">,<\/span> torch<span class=\"token punctuation\">.<\/span>cuda<span class=\"token punctuation\">.<\/span>current_device<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;GPU\u540d\u79f0:&#034;<\/span><span class=\"token punctuation\">,<\/span> torch<span class=\"token punctuation\">.<\/span>cuda<span class=\"token punctuation\">.<\/span>get_device_name<span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u5982\u679c\u8f93\u51fa\u663e\u793aCUDA\u53ef\u7528&#xff0c;\u5e76\u4e14\u80fd\u591f\u6b63\u786e\u663e\u793aGPU\u4fe1\u606f&#xff0c;\u8bf4\u660ePyTorch\u5df2\u6210\u529f\u5b89\u88c5\u5e76\u652f\u6301GPU\u52a0\u901f\u3002<\/p>\n<h4>5. \u5b89\u88c5\u5e38\u7528\u7684PyTorch\u76f8\u5173\u5e93<\/h4>\n<p><span class=\"token comment\"># \u5b89\u88c5\u5e38\u7528\u7684\u6570\u636e\u5904\u7406\u548c\u53ef\u89c6\u5316\u5e93<\/span><br \/>\nconda <span class=\"token function\">install<\/span> pandas matplotlib scikit-learn jupyter<\/p>\n<p><span class=\"token comment\"># \u5b89\u88c5\u5176\u4ed6PyTorch\u751f\u6001\u7cfb\u7edf\u5de5\u5177<\/span><br \/>\npip <span class=\"token function\">install<\/span> pytorch-lightning<br \/>\npip <span class=\"token function\">install<\/span> transformers<br \/>\npip <span class=\"token function\">install<\/span> timm  <span class=\"token comment\"># \u8ba1\u7b97\u673a\u89c6\u89c9\u6a21\u578b\u5e93<\/span><\/p>\n<h3>\u4e03\u3001\u5b89\u88c5\u5176\u4ed6\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6&#xff08;\u53ef\u9009&#xff09;<\/h3>\n<h4>\u5b89\u88c5TensorFlow<\/h4>\n<p>conda <span class=\"token function\">install<\/span> -c conda-forge tensorflow-gpu<\/p>\n<p>\u9a8c\u8bc1TensorFlow GPU\u652f\u6301&#xff1a;<\/p>\n<p><span class=\"token keyword\">import<\/span> tensorflow <span class=\"token keyword\">as<\/span> tf<br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;TensorFlow\u7248\u672c:&#034;<\/span><span class=\"token punctuation\">,<\/span> tf<span class=\"token punctuation\">.<\/span>__version__<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;GPU\u662f\u5426\u53ef\u7528:&#034;<\/span><span class=\"token punctuation\">,<\/span> tf<span class=\"token punctuation\">.<\/span>config<span class=\"token punctuation\">.<\/span>list_physical_devices<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;GPU&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<h3>\u516b\u3001\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848<\/h3>\n<h4>1. CUDA\u7248\u672c\u4e0e\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u4e0d\u517c\u5bb9<\/h4>\n<p>\u786e\u4fdd\u5b89\u88c5\u7684CUDA\u3001cuDNN\u7248\u672c\u4e0e\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u517c\u5bb9\u3002\u53ef\u4ee5\u53c2\u8003\u6846\u67b6\u5b98\u65b9\u6587\u6863\u4e2d\u7684\u7248\u672c\u517c\u5bb9\u6027\u8bf4\u660e\u3002<\/p>\n<h4>2. \u73af\u5883\u53d8\u91cf\u914d\u7f6e\u9519\u8bef<\/h4>\n<p>\u68c0\u67e5~\/.bashrc\u6587\u4ef6\u4e2d\u7684\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u662f\u5426\u6b63\u786e&#xff0c;\u8def\u5f84\u662f\u5426\u5bf9\u5e94\u5b9e\u9645\u5b89\u88c5\u4f4d\u7f6e\u3002<\/p>\n<h4>3. \u591a\u4e2aCUDA\u7248\u672c\u5171\u5b58<\/h4>\n<p>\u5982\u679c\u9700\u8981\u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5\u591a\u4e2aCUDA\u7248\u672c&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u63a7\u5236\u4f7f\u7528\u54ea\u4e2a\u7248\u672c&#xff1a;<\/p>\n<p><span class=\"token builtin class-name\">export<\/span> <span class=\"token assign-left variable\">CUDA_HOME<\/span><span class=\"token operator\">&#061;<\/span>\/usr\/local\/cuda-X.Y<br \/>\n<span class=\"token builtin class-name\">export<\/span> <span class=\"token assign-left variable\"><span class=\"token environment constant\">PATH<\/span><\/span><span class=\"token operator\">&#061;<\/span><span class=\"token variable\">$CUDA_HOME<\/span>\/bin:<span class=\"token environment constant\">$PATH<\/span><br \/>\n<span class=\"token builtin class-name\">export<\/span> <span class=\"token assign-left variable\">LD_LIBRARY_PATH<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token variable\">$CUDA_HOME<\/span>\/lib64:<span class=\"token variable\">$LD_LIBRARY_PATH<\/span><\/p>\n<h4>4. \u5185\u5b58\u4e0d\u8db3<\/h4>\n<p>\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u8bad\u7ec3\u53ef\u80fd\u9700\u8981\u5927\u91cfGPU\u5185\u5b58&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u89e3\u51b3&#xff1a;<\/p>\n<ul>\n<li>\u51cf\u5c0f\u6279\u91cf\u5927\u5c0f(batch size)<\/li>\n<li>\u4f7f\u7528\u6df7\u5408\u7cbe\u5ea6\u8bad\u7ec3<\/li>\n<li>\u5b9e\u73b0\u68af\u5ea6\u7d2f\u79ef<\/li>\n<li>\u4f7f\u7528\u6a21\u578b\u5e76\u884c\u6216\u6570\u636e\u5e76\u884c<\/li>\n<\/ul>\n<h4>5. PyTorch\u5b89\u88c5\u540e\u65e0\u6cd5\u8bc6\u522bGPU<\/h4>\n<p>\u5982\u679cPyTorch\u5b89\u88c5\u540e\u65e0\u6cd5\u8bc6\u522bGPU&#xff0c;\u53ef\u80fd\u7684\u539f\u56e0\u5305\u62ec&#xff1a;<\/p>\n<ul>\n<li>CUDA\u7248\u672c\u4e0ePyTorch\u4e0d\u517c\u5bb9<\/li>\n<li>\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u9519\u8bef<\/li>\n<li>GPU\u9a71\u52a8\u7248\u672c\u8fc7\u4f4e<\/li>\n<\/ul>\n<p>\u89e3\u51b3\u65b9\u6cd5&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u68c0\u67e5CUDA\u662f\u5426\u6b63\u786e\u5b89\u88c5<\/span><br \/>\nnvcc &#8211;version<\/p>\n<p><span class=\"token comment\"># \u786e\u4fdd\u5b89\u88c5\u4e86\u4e0eCUDA\u7248\u672c\u517c\u5bb9\u7684PyTorch<\/span><br \/>\n<span class=\"token comment\"># \u4f8b\u5982&#xff0c;\u5bf9\u4e8eCUDA 11.7&#xff0c;\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u91cd\u65b0\u5b89\u88c5PyTorch<\/span><br \/>\nconda <span class=\"token function\">install<\/span> pytorch torchvision torchaudio pytorch-cuda<span class=\"token operator\">&#061;<\/span><span class=\"token number\">11.7<\/span> -c pytorch -c nvidia<\/p>\n<p><span class=\"token comment\"># \u68c0\u67e5\u73af\u5883\u53d8\u91cf<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token environment constant\">$PATH<\/span> <span class=\"token operator\">|<\/span> <span class=\"token function\">grep<\/span> cuda<br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token variable\">$LD_LIBRARY_PATH<\/span> <span class=\"token operator\">|<\/span> <span class=\"token function\">grep<\/span> cuda<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb729\u6b21\uff0c\u70b9\u8d5e25\u6b21\uff0c\u6536\u85cf10\u6b21\u3002\u5728\u6df1\u5ea6\u5b66\u4e60\u548c\u79d1\u5b66\u8ba1\u7b97\u9886\u57df\uff0c\u6b63\u786e\u914d\u7f6eGPU\u52a0\u901f\u73af\u5883\u5bf9\u4e8e\u63d0\u9ad8\u8ba1\u7b97\u6548\u7387\u81f3\u5173\u91cd\u8981\u3002\u6211\u8bb0\u5f55\u4e86\u5728\u670d\u52a1\u5668\u4e0a\u914d\u7f6eCUDA\u3001cuDNN\u3001Anaconda\u4ee5\u53ca\u76f8\u5e94\u7684Python\u73af\u5883\u7684\u8fc7\u7a0b\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[43,3121,86],"topic":[],"class_list":["post-36244","post","type-post","status-publish","format-standard","hentry","category-server","tag-43","tag-3121","tag-86"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u670d\u52a1\u5668\u4e0a\u914d\u7f6eCUDA\u3001cuDNN\u3001Anaconda\u548cPython\u73af\u5883\u7684\u5b8c\u6574\u8fc7\u7a0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/36244.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u670d\u52a1\u5668\u4e0a\u914d\u7f6eCUDA\u3001cuDNN\u3001Anaconda\u548cPython\u73af\u5883\u7684\u5b8c\u6574\u8fc7\u7a0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb729\u6b21\uff0c\u70b9\u8d5e25\u6b21\uff0c\u6536\u85cf10\u6b21\u3002\u5728\u6df1\u5ea6\u5b66\u4e60\u548c\u79d1\u5b66\u8ba1\u7b97\u9886\u57df\uff0c\u6b63\u786e\u914d\u7f6eGPU\u52a0\u901f\u73af\u5883\u5bf9\u4e8e\u63d0\u9ad8\u8ba1\u7b97\u6548\u7387\u81f3\u5173\u91cd\u8981\u3002\u6211\u8bb0\u5f55\u4e86\u5728\u670d\u52a1\u5668\u4e0a\u914d\u7f6eCUDA\u3001cuDNN\u3001Anaconda\u4ee5\u53ca\u76f8\u5e94\u7684Python\u73af\u5883\u7684\u8fc7\u7a0b\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/36244.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-08T14:35:54+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/36244.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/36244.html\",\"name\":\"\u670d\u52a1\u5668\u4e0a\u914d\u7f6eCUDA\u3001cuDNN\u3001Anaconda\u548cPython\u73af\u5883\u7684\u5b8c\u6574\u8fc7\u7a0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-08T14:35:54+00:00\",\"dateModified\":\"2025-05-08T14:35:54+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/36244.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/36244.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/36244.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u670d\u52a1\u5668\u4e0a\u914d\u7f6eCUDA\u3001cuDNN\u3001Anaconda\u548cPython\u73af\u5883\u7684\u5b8c\u6574\u8fc7\u7a0b\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u670d\u52a1\u5668\u4e0a\u914d\u7f6eCUDA\u3001cuDNN\u3001Anaconda\u548cPython\u73af\u5883\u7684\u5b8c\u6574\u8fc7\u7a0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/36244.html","og_locale":"zh_CN","og_type":"article","og_title":"\u670d\u52a1\u5668\u4e0a\u914d\u7f6eCUDA\u3001cuDNN\u3001Anaconda\u548cPython\u73af\u5883\u7684\u5b8c\u6574\u8fc7\u7a0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb729\u6b21\uff0c\u70b9\u8d5e25\u6b21\uff0c\u6536\u85cf10\u6b21\u3002\u5728\u6df1\u5ea6\u5b66\u4e60\u548c\u79d1\u5b66\u8ba1\u7b97\u9886\u57df\uff0c\u6b63\u786e\u914d\u7f6eGPU\u52a0\u901f\u73af\u5883\u5bf9\u4e8e\u63d0\u9ad8\u8ba1\u7b97\u6548\u7387\u81f3\u5173\u91cd\u8981\u3002\u6211\u8bb0\u5f55\u4e86\u5728\u670d\u52a1\u5668\u4e0a\u914d\u7f6eCUDA\u3001cuDNN\u3001Anaconda\u4ee5\u53ca\u76f8\u5e94\u7684Python\u73af\u5883\u7684\u8fc7\u7a0b\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/36244.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-08T14:35:54+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/36244.html","url":"https:\/\/www.wsisp.com\/helps\/36244.html","name":"\u670d\u52a1\u5668\u4e0a\u914d\u7f6eCUDA\u3001cuDNN\u3001Anaconda\u548cPython\u73af\u5883\u7684\u5b8c\u6574\u8fc7\u7a0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-08T14:35:54+00:00","dateModified":"2025-05-08T14:35:54+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/36244.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/36244.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/36244.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u670d\u52a1\u5668\u4e0a\u914d\u7f6eCUDA\u3001cuDNN\u3001Anaconda\u548cPython\u73af\u5883\u7684\u5b8c\u6574\u8fc7\u7a0b"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/36244","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=36244"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/36244\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=36244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=36244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=36244"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=36244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}