WIN11 + CUDA11.7配置深度学习开发环境(一)

#视频截取的模型
训练开发的视频截取器,公司给发的电脑,在这里记录一下环境配置的过程,由于已经安装了cuda等环境(我也不想重新下载啦),就利用11.7做这个练习。以后遇到问题在解决。
首先给出参考经验帖。[这个电脑是RTX3050+win11]
(https://blog.csdn.net/x242510/article/details/123069195)
##检查cuda是否安装成功的方法:
###1.使用shell命令行(nvidia-smi)

Thu Dec 15 14:25:46 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 517.48       Driver Version: 517.48       CUDA Version: 11.7     |
|-------------------------------+----------------------+----------------------+
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ... WDDM  | 00000000:01:00.0 Off |                  N/A |
| N/A   43C    P3    17W /  N/A |      0MiB /  4096MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

###方法二:找到Nvidia control Panel
找到系统信息
这里就是cuda的版本内容
##2. 运行时API(Runtime API)
命令行输入nvcc -V

也可以参考这篇文章cuda基础
#安装过程
参考这两篇文章(Win11Win11 + RTX3060 配置Cuda等深度学习环境),先按照别人的经验走一遍,在最后搞自己的版本,就像大一开始装电脑一样,没接触的东西多尝试几次。
##环境变量配置

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\lib

环境检查

cd C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7

cd extras\demo_suite

.\bandwidthTest.exe

环境检查在命令行显示的结果
##下载相对应的python包,不想出问题的话,按照一步步来。我在测试学习3.9的环境,一起学习吧。

>>> import tensorflow as tf
>>> tf.reduce_sum(tf.random.normal([1000, 1000])

结果是这个东西

WARNING:tensorflow:From <stdin>:1: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.config.list_physical_devices('GPU')` instead.
2022-12-16 08:54:52.073841: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-12-16 08:54:55.279269: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1510] Created device /device:GPU:0 with 1666 MB memory:  -> device: 0, name: NVIDIA GeForce RTX 3050 Laptop GPU, pci bus id: 0000:01:00.0, compute capability: 8.6

这个显示一下GPU,这里还没有搞懂怎么回事(需要搞清楚)

>>> tf.config.list_physical_devices('GPU')
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
>>> version = tf.version
>>> gpu_ok = tf.test.is_gpu_available()

打印自己的GPU,这样应该没问题啦

>>> print("tf version:",version,"\nuse GPU",gpu_ok)
tf version: <module 'tensorflow._api.v2.version' from 'C:\\Program Files\\Anaconda\\lib\\site-packages\\tensorflow\\_api\\v2\\version\\__init__.py'>
use GPU True
CUDA (Compute Unified Device Architecture)种由 NVIDIA 开发的并行计算平台和编程模型,用于加速深度学习、科学计算等高性能应用程序。CUDA 11.7CUDA个版本,针对 Windows 11 系统进行了优化。 要在 Windows 11 上安装 PyTorch(个流行的深度学习库),同时支持 CUDA 11.7,你需要按照以下步骤操作: 1. **检查系统兼容性**:确保你的显卡支持 CUDA,并且满足 CUDA 11.7 的最低硬件要求。访问 NVIDIA Developer网站查询兼容列表:https://developer.nvidia.com/cuda-gpus 2. **下载 CUDA Toolkit**:访问 https://www.nvidia.com/zh-cn/accelerated-computing/software-development-toolkit 下载 CUDA SDK,选择适用于 Windows 11 的版本。 3. **安装 CUDA**:运行安装文件,遵循提示完成安装过程。记得在安装过程中勾选 "Add Cuda PATH to environment variables" 选项,以便 Python 能够识别 CUDA。 4. **安装 cuDNN**:CUDA 还需要 cuDNN(深度神经网络库)的支持,可以从 NVIDIA Developer Center 获取:https://developer.nvidia.com/cudnn 5. **安装 PyTorch with CUDA support**:打开命令提示符或 PowerShell,确保已经设置了环境变量,然后使用以下命令安装 PyTorch: ```shell pip install torch torchvision cudatoolkit=11.7 -f https://download.pytorch.org/whl/cu116/torch_stable.html ``` 6. **验证安装**:安装完成后,你可以通过 `torch.cuda.is_available()` 来检查是否成功安装了 CUDA 和 PyTorch GPU 后台。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

深秋青花

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值