目录

pycharm添加虚拟环境以及虚拟环境安装pytorch

  1. file、settings、interpreter、add interpreter、add local interpreter

    记住不要勾选inherit,不然会把主环境的东西继承到虚拟环境。

    创建前可以先点existing看看有没有已经建好的虚拟环境

  2. 有的时候pycharm有问题,创建了虚拟环境没有显示。找一个.py文件,上方会弹出提醒,选择使用interpreter,选择刚刚建好的虚拟环境。

  3. 记得重新打开terminal,如果前面有(venv),说明是在虚拟环境中。

  4. pytorch官网,pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

  5. 运行一段代码,调用gpu看看行不行

    import torch

    if torch.cuda.is_available():
    print("检测到当前设备有可用GPU:")
    print("当前可用GPU数量:", torch.cuda.device_count())
    print("当前GPU索引:", torch.cuda.current_device())
    print("当前GPU名称:", torch.cuda.get_device_name(torch.cuda.current_device()))
    else:
    print("未检测到当前设备有可用GPU,不建议开始训练,如有需求请自行更改代码:")
    exit()

成功!

本文是转载文章,点击查看原文
如有侵权,请联系 xyy@jishuzhan.net 删除
相关推荐
Cl_rown去掉l变成C1 小时前
第P10周:Pytorch实现车牌识别
人工智能·pytorch·python
AIGC_ZY2 小时前
PyTorch 实现图像版多头注意力(Multi-Head Attention)和自注意力(Self-Attention)
人工智能·pytorch·python
xuebodx09234 小时前
私有部署stable-diffusion-webui
图像处理·pytorch·ai作画·stable diffusion·视觉检测·transformer·dall·e 2
小白的高手之路5 小时前
torch.nn中的非线性激活介绍合集——Pytorch中的非线性激活
人工智能·pytorch·python·深度学习·神经网络·机器学习·cnn
xy_optics8 小时前
Unet网络的Pytorch实现和matlab实现
网络·pytorch·matlab
过期动态12 小时前
【动手学深度学习】卷积神经网络(CNN)入门
人工智能·python·深度学习·pycharm·cnn·numpy
车斗17 小时前
win10 笔记本电脑安装 pytorch+cuda+gpu 大模型开发环境过程记录
人工智能·pytorch·电脑
意.远20 小时前
PyTorch参数管理详解:从访问到初始化与共享
人工智能·pytorch·python·深度学习
weixin_398187751 天前
YOLOv11训练教程:PyTorch与PyCharm在Windows 11下的完整指南
pytorch·yolo·pycharm
Hiweir ·1 天前
pyTorch框架使用CNN进行手写数字识别
人工智能·pytorch·cnn