图机器学习踩坑记录,有解决方式

2024.5.14

  1. __init__函数是 两个下划线开头的函数是声明该属性为私有,不能在类的外部被使用或访问。而__init__函数(方法)支持带参数类的初始化,也可为声明该类的属性(类中的变量)。__init__函数(方法)的第一个参数必须为self,后续参数为自己定义。
#!/usr/bin/python
# -*- coding utf-8 -*-
#Created by Lu Zhan
 
class Box:
    def setDimension(self, width, height, depth):
        self.width = width
        self.height = height
        self.depth = depth
 
    def getVolume(self):
        return self.width * self.height * self.depth
 
b = Box()
b.setDimension(10, 20, 30)
print(b.getVolume())

2024.5.19

  1. 安装dgl或pyg时安装了低版本的torch, 导致了版本冲突,
The following packages are causing the inconsistency:

  - pyg/win-64::pyg==2.5.2=py38_torch_1.13.0_cpu
  1. 当时没事,第二天打开电脑突然报错
[WinError 127] 找不到指定的程序。 Error loading "F:\Anaconda\envs\HMCAN\lib\site-packages\torch\lib\c10_cuda.dll" or one of its dependencies.

寻找了多种办法,发现卸载时没卸载干净

(HMCAN) E:\Download>pip uninstall torch
Found existing installation: torch 2.1.1+cu118
Uninstalling torch-2.1.1+cu118:
  Would remove:
    f:\anaconda\envs\hmcan\lib\site-packages\nvfuser\*
    f:\anaconda\envs\hmcan\lib\site-packages\torch-2.1.1+cu118.dist-info\*
Proceed (Y/n)? y
  Successfully uninstalled torch-2.1.1+cu118
  1. 重新卸载后,最终决定重装torch,结果安装都报错,但是site-package中torchvision等都在打算手动离线下载,pytorch2.1.1-cu118版本,下载好whl文件后,cd到文件对应位置,pip install 文件名,离线安装。

  2. 但是!!dgl cuda版本的还是不能用,因为版本与torch2.1.1+cu118不匹配,即:FileNotFoundError: Cannot find DGL C++ graphbolt library at ...

原因是:默认的cu118版本的dgl对应torch是1.13版,懒得重新创建虚拟环境安装torch了,所以替换为win-64_dgl-1.1.2-py38_0.tar版本,下载链接为:dgl-cpu,安装教程为:dgl安装教程完整版

最后发现自己离线安装了cuda版本,是正确的,实际上是可以使用的,只是pycahrm中一些函数会报警告,并不是安装错误。真的是误区哇。pycharm的问题。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值