一些bug的简单记录及可能的解决方法:安装模块,更新失败,显卡问题

本文档总结了PyTorch与CUDA环境配置过程中遇到的典型问题及其解决方案,包括环境配置错误、语法错误、模块缺失、设备类型不匹配等,并提供了VSCode更新失败的解决方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.Defaulting to user installation because normal site-packages is not writeable。

ERROR: Operation cancelled by user
已配置的文件无法修改,建议重新搭个环境,最快。
比如pytorch
https://download.pytorch.org/whl/torch_stable.html
下个torch稳定版

2.targets.cuda(async=True)

Syntax Error: invalid syntax:
修改为inputs, targets = inputs.cuda(), targets.cuda()即可

3.ModuleNotFoundError:No module named‘past’

解决方法安装future模块

4.No space left on device

需要手动清除文件特别是使用 nohup 命令时,所有的输出都会被不断地添加到同一个文件中,如果该进程不会自己终止,就可能导致输出文件占满整个磁盘。
还会出现下面的情况:明明已经安装的模块竟然找不到。
在这里插入图片描述
在这里插入图片描述

5.RuntimeError: expected device cuda:0 and dtype Float but got device cpu and dtype Float

loss = loss.cuda() 转化下类型,或者debug看看,有时是float,long,int比较灵活。

6.VSCode 更新失败的解决方法

https://blog.csdn.net/cjhxydream/article/details/107246909

7.Pytorch高版本(1.0)跑程序出现的几个错误

https://blog.csdn.net/bluehatihati/article/details/89154417

8.maven install 坑

https://blog.csdn.net/r1001020713/article/details/90106416?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-.control&dist_request_id=a324e51f-dd07-43c4-a7a9-338253981613&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control

9.指定显卡

命令行用export CUDA_VISIBLE_DEVICES=1 #id可换成别的
不用在程序中写torch.cuda.set_device(‘cuda:’+str(gpu_ids))
这种写法的优先级低,如果model.cuda()中指定了参数,那么torch.cuda.set_device()会失效

10 torch与cuda不匹配问题

解决PyTorch与CUDA版本不匹配
https://blog.csdn.net/weixin_42069606/article/details/105198845?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.control

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值