win10系统配置GPU版本Pytorch的详细教程
作者:SGchi 时间:2023-07-21 19:30:38
一、安装cuda
1、在英伟达官网下载最新版的cuda驱动
https://developer.nvidia.com/zh-cn/cuda-downloads
都选上就行了,然后一路默认安装
输入nvcc -V查看是否安装成功
二、安装pycuda
1、在控制台中输入pip install pycuda 安装pycuda
2、在环境变量中添加cl.exe
3、测试pycuda是否正常运行
import pycuda.driver as drv
import pycuda.tools,pycuda.autoinit,numpy
import numpy.linalg as la
from pycuda.compiler import SourceModule
mod = SourceModule("""
__global__ void multiply_them(float *dest, float *a, float *b)
{
const int i = threadIdx.x;
dest[i] = a[i] * b[i];
}
""")
multiply_them = mod.get_function("multiply_them")
a = numpy.random.randn(400).astype(numpy.float32)
b = numpy.random.randn(400).astype(numpy.float32)
dest = numpy.zeros_like(a)
multiply_them(drv.Out(dest), drv.In(a), drv.In(b),block=(400,1,1))
print(dest-a*b)
全为0说明GPU计算结果跟CPU一样
三、安装GPU版本的pytorch
进入pytorch官网
附:遇到的问题及解决办法:
1、刚装好的时候可以加载pycuda,但是无法找到模块
经过我的分析应该是刚安装好系统不是很稳定,我重启了一下电脑解决了问题
2、更改了PATH变量后无反映
修改系统变量后要重启电脑后才能生效
3、在系统变量中添加某个程序时,要添加他上一级目录,不用指定到具体哪个程序。
来源:https://blog.csdn.net/SGchi/article/details/116241998
标签:win10,GPU,Pytorch
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python开发微信公众平台的方法详解【基于weixin-knife】
2023-03-09 12:05:43
python实现根据图标提取分类应用程序实例
2022-07-23 16:22:39
Python+OpenCV 实现图片无损旋转90°且无黑边
2021-11-09 17:04:12
![](https://img.aspxhome.com/file/2023/9/105029_0s.jpg)
用Python写个新年贺卡生成器
2023-08-26 00:56:45
![](https://img.aspxhome.com/file/2023/5/95725_0s.jpg)
解决python matplotlib imshow无法显示的问题
2023-07-19 23:59:25
详解django中url路由配置及渲染方式
2021-04-29 01:28:50
![](https://img.aspxhome.com/file/2023/5/77035_0s.png)
asp连接mssql2005的代码
2011-03-29 11:11:00
Mysql5写中文乱码问题解决
2007-09-17 12:38:00
通过格式良好的SQL提高效率和准确性
2024-01-21 21:16:27
![](https://img.aspxhome.com/file/2023/4/85584_0s.png)
SQL Server中的逻辑函数介绍
2024-01-20 06:20:37
![](https://img.aspxhome.com/file/2023/7/96137_0s.png)
Python使用matplotlib.pyplot as plt绘图图层优先级问题
2022-06-10 18:00:37
![](https://img.aspxhome.com/file/2023/7/133557_0s.png)
Python Requests 基础入门
2022-01-19 10:58:36
Python实现遗传算法(虚拟机中运行)
2022-07-10 18:48:07
![](https://img.aspxhome.com/file/2023/1/66881_0s.jpg)
Go语言Zap库Logger的定制化和封装使用详解
2024-04-25 15:18:52
python ip正则式
2022-02-13 22:13:02
Fuse.js模糊查询算法学习指南
2024-04-19 11:02:54
PHP 动态生成静态HTML页面示例代码
2024-05-02 17:18:13
Python爬虫之Selenium多窗口切换的实现
2021-09-25 17:48:48
python import 引用上上上级包的三种方法
2021-09-22 12:56:38
git 报错:OpenSSL SSL_read: Connection was reset, errno 10054 解决方法
2022-12-23 11:55:00