当前位置:网站首页>Pytorch问题总结
Pytorch问题总结
2022-08-04 05:29:00 【视觉菜鸟Leonardo】
1.使用多线程时报错:
将程序加入到
if __name__ == "__main__" 中

Pytorch使用多线程加载数据报错_Restart丶的博客-CSDN博客_pytorch多线程加载数据
2.使用jupyter时,报错:内核挂掉了,需要重启

解决:加入以下代码![]()
结果:

jupyter notebook内核挂掉了,需要重启_取个名字真难呐的博客-CSDN博客_挂掉的内核
3.导入torchvision时,报错:python无法找到入口,无法定位程序输入点

问题:torch版本和torchvision版本不对应,需要查看版本,卸载后重新下载

https://github.com/pytorch/vision#installation
4.使用graphviz查看网络结构图时报错:
ExecutableNotFound: failed to execute [‘dot’, ‘-Tsvg’], make sure the Graphviz executables are on your systems
不仅要在conda中下载graphviz,还需要去官网下载一个软件并且配置到环境变量中
注意:先安装软件再用conda下载graphviz,不然一定报错
安装graphviz和python -graphviz
5.NotImplementedError报错:

问题:(1)定义前向传播的函数 forward()出问题,检查:
①函数名拼写对不对
②函数格式有没有对齐,或者对齐错误
(2)定义的类中,def 函数没有对齐

6.ValueError: num must be 1 <= num <= 6, not 9
如果三个整数是行数、列数和索引值,子图将分布在行列的索引位置上。索引从1开始,从右上角增加到右下角。
在使用plt.subplot(a,b,c)时,函数代表有a行b列,c代表索引值,c会根据行列数来自动判断位于第几行第几列
a=3,b=4,c=1:3行4列的图像组合,此图像位于第一行第一个
a=3,b=4,c=4:3行4列的图像组合,此图像位于第一行第四个
a=3,b=4,c=5:3行4列的图像组合,此图像位于第二行第一个
注意:c<=a*b
6. OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.

在最开头引入:(允许副本存在)
import os
os.environ['KMP_DUPLICATE_LIB_OK']='True'
7.RuntimeError: CUDA out of memory. Tried to allocate 20.00 MiB (GPU 0; 4.00 GiB total capacity; 2.44
gpu显卡内存不足,可以打开任务管理器查看

也可以在控制台中输入 nvidia-smi查看:

解决:在报错的语句上面一行加入:
if hasattr(torch.cuda, 'empty_cache'):
torch.cuda.empty_cache()也可以(1)重启电脑
(2)关掉后台PID对应的python程序(重启内核)

边栏推荐
猜你喜欢
随机推荐
安装dlib踩坑记录,报错:WARNING: pip is configured with locations that require TLS/SSL
(十四)平衡二叉树
属性动画的用法 以及ButterKnife的用法
[Introduction to go language] 12. Pointer
read and study
Logistic Regression --- Introduction, API Introduction, Case: Cancer Classification Prediction, Classification Evaluation, and ROC Curve and AUC Metrics
fill_between in Matplotlib; np.argsort() function
Briefly say Q-Q map; stats.probplot (QQ map)
TensorFlow2 study notes: 7. Optimizer
【CV-Learning】语义分割
postgres 递归查询
Various commands such as creating a new user in postgresql
TensorFlow2 study notes: 8. tf.keras implements linear regression, Income dataset: years of education and income dataset
sklearn中的pipeline机制
剑指 Offer 2022/7/1
图像合并水平拼接
TensorFlow2学习笔记:8、tf.keras实现线性回归,Income数据集:受教育年限与收入数据集
SQL练习 2022/6/30
[Deep Learning 21-Day Learning Challenge] 3. Use a self-made dataset - Convolutional Neural Network (CNN) Weather Recognition
SQL练习 2022/7/4








