针对解决conda环境BUG的个人笔记

发布于:2024-12-07 ⋅ 阅读:(20) ⋅ 点赞:(0)

1-conda学习&安装

安装视频:

零基础教程:基于Anaconda和PyCharm配置Pytorch环境_哔哩哔哩_bilibili

安装过程:

MX250笔记本安装Pytorch、CUDA和cuDNN-CSDN博客

Win10+MX250+CUDA10.1+cuDNN+Pytorch1.4安装+测试全过程(吐血)_nvidia geforce mx250 显卡可以装gpu加速吗-CSDN博客

资料下载:

cuda 10.1 下载_cuda10.1下载-CSDN博客

问题总结:

我的问题:

1、torch.cuda.is_avaliable()在命令行里是true,但是pycharm是false

2、pycharm选择pytorch所在的解释器,加载失败。

3、pytorch所在的解释器加载成功,但是里边的torch包莫名消失。

解决方法:

在调试了很多torch版本、python版本、cuda版本后,无计可施,尝试了一下低版本的pycharm

开始用的2024版,命令行里是true,但是pycharm是false。

换成了2021版,加载解释器便顺利了,torch.cuda.is_avaliable()结果True。

问题:

jupyter没有输出,无法保存。

jupyter notebook报错:Bad file descriptor(C:\ci\zeromq_1602704446950\work\src\epoll.cpp:100)_jupyter notebook bad file descriptor-CSDN博客

解决方法:

问题是pyzmq版本问题,卸载pyzmq 22.0.2,执行 conda install pyzmq==19.0.2  安装pyzmq 19.0.2。

问题:

import os

root_dir = "pythonProject/dataset/train"

ants_label_dir="ants"

path = os.path.join(root_dir, ants_label_dir)

img_path = os.listdir(path)

在使用listdir函数时,出现路径错误问题。

解决方法:

使用相对路径。

在使用join函数时:

"pythonProject/dataset/train"+”ants” = pythonProject/dataset/train\\ants

"pythonProject/dataset/train/"+”ants” = pythonProject/dataset/train/ants

问题:

from torch.utils.tensorboard import SummaryWriter导入不成功问题

from torch.utils.tensorboard import SummaryWriter导入不成功问题_tensorboard 无法import summarywriter-CSDN博客

解决方法:

#由于pytorch本身不自带tensorboard包,一般这样报错都是由于未安装tensorboard包导致的。

#可以通过pip 加载清华镜像源进行安装

sudo pip install  -i https://mirrors.aliyun.com/pypi/simple/ tensorboard

如果正确安装tensorboard之后,重新运行代码,还是报错找不到在torch.utils.tensorboard中找不到SummaryWriter该怎么办。

别着急,因为SummaryWriter是存在于tensorboardX(其作为tensorboard的子模块)因此同样通过pip进行安装:

sudo pip install  -i https://mirrors.aliyun.com/pypi/simple/ tensorboardX

如果正确安装tensorboardX依旧找不到SummaryWriter

请将报错的:

        from torch.utils.tensorboard import SummaryWriter

改为:    

        from tensorboardX import SummaryWriter

问题:

绘图失败

ValueError: Duplicate plugins for name projector

成功解决ValueError: Duplicate plugins for name projector-CSDN博客

pip uninstall tb-nightly tensorboard tensorflow tensorflow-estimator

pip install tensorflow

就行了

然后又把命令改为绝对路径

tensorboard --logdir=绝对地址


2-升级CUDA_服务器升级cuda版本

Linux服务器安装\升级CUDA_服务器升级cuda版本-CSDN博客

直接显示系统架构uname -m 命令可以快速直接地显示Linux系统的架构。例如,输出“x86_64”表明是64位系统,而“i686”或“i386”则表示为32位系统

查看所有版本信息lsb_release -a 命令能够列出所有的版本信息,包括发行版ID、描述、版本号和代号。这个命令广泛适用于包括Redhat、SuSE、Debian等在内的多种Linux发行版。


3- 多个CUDA版本自由切换方法

多个CUDA版本自由切换方法 - 哔哩哔哩 (bilibili.com)


4-Linux操作系统:如何在环境中安装并打开Jupyter_Notebook

Linux操作系统:如何在环境中安装并打开Jupyter_Notebook_哔哩哔哩_bilibili


5-WSL2 Ubuntu20.04 打开language support闪退解决办法

WSL2 Ubuntu20.04 打开language support闪退解决办法_wsl闪退-CSDN博客


6-ubuntu安装搜狗输入法

ubuntu安装搜狗输入法,图文详解+踩坑解决-CSDN博客

配合

在Ubuntu20.04安装fcitx输入法框架

在Ubuntu20.04安装fcitx输入法框架_ubuntu fcitx-CSDN博客


7-Nvidia显卡Failed to initialize NVML Driver/library version mismatch错误解决方案

Nvidia显卡Failed to initialize NVML Driver/library version mismatch错误解决方案_driverlibrary version mismatch-CSDN博客


8-通过命令行快速安装pytorch2.0(GPU)

通过命令行快速安装pytorch2.0(GPU)_torch==2.0.1+cu118 国内镜像-CSDN博客


9-Pytorch 搭建自己的Faster-RCNN目标检测平台

Train2-(训练必看)训练自己的数据集_哔哩哔哩_bilibili


10-numpy

AttributeError: module 'numpy' has no attribute 'object'. `np.object` was a deprecated alias for the builtin `object`. To avoid this error in existing code, use `object` by itself. Doing this will not modify any behavior and is safe.

再运行下面代码

pip install numpy==1.22.0 -i https://pypi.tuna.tsinghua.edu.cn/simple --user

AttributeError: module ‘numpy‘ has no attribute ‘object‘.解决方法_attributeerror: module 'numpy' has no attribute 'o-CSDN博客


 11

 File "/mnt/easy_detection-master/utils/vis.py", line 248, in <listcomp>

    display_str_heights = [font.getsize(ds)[1] for ds in display_str_list]

AttributeError: 'ImageFont' object has no attribute 'getsize'

这是因为安装了新版本的 Pillow (10)删除了该getsize 功能

,降级到 Pillow 9.5 解决了该问题

可以尝试以下方法进行解决:

pip install Pillow==9.5

已解决:attributeerror: ‘FreeTypeFont‘ object has no attribute ‘getsize‘_attributeerror: 'freetypefont' object has no attri-CSDN博客

 


12-torch2.x导入timm预训练模型时报错ModuleNotFoundError: No module named ‘torch._six

torch2.x导入timm预训练模型时报错ModuleNotFoundError: No module named ‘torch._six‘-CSDN博客


 13-VOC数据集转COCO数据集

【数据集转换】VOC数据集转COCO数据集·代码实现+操作步骤_如何把数据整理成coco数据集-CSDN博客


 14-YOLOX报错:AttributeError: FigureCanvasTkAgg object has no attribute set_window_title

YOLOX报错:AttributeError: FigureCanvasTkAgg object has no attribute set_window_title_attributeerror: 'figurecanvastkagg' object has no -CSDN博客


 15-Jupyter notebook 使用matplotlib画图出现kernel died问题

运行至plt画图部分弹出 Kernel Restarting. The kernel appreas to have died.

参考 https://stackoverflow.com/questions/65734044/kernel-appears-to-have-died-jupyter-notebook-python-matplotlib

添加环境变量

import os

os.environ[‘KMP_DUPLICATE_LIB_OK’] = ‘True’

Jupyter notebook 使用matplotlib画图出现kernel died问题_jupyterplot函数导致kernel崩溃-CSDN博客

 


16-Failed to build dlib ERROR: Could not build wheels for dlib, which is required to install pypro

conda install -c conda-forge dlib

【已解决】Failed to build dlib ERROR: Could not build wheels for dlib, which is required to install pypro-CSDN博客


 17-ImportError: cannot import name ‘RootModel‘ from ‘pydantic‘

conda install gradio=3.48.0

ImportError: cannot import name ‘RootModel‘ from ‘pydantic‘_importerror: cannot import name 'rootmodel' from '-CSDN博客


 18-解决centos(linux) ffmepg 支持 h264 mp4 编码方法 Unknown encoder ‘h264‘

解决centos(linux) ffmepg 支持 h264 mp4 编码方法 Unknown encoder ‘h264‘_ffmpeg unknown encoder 'h264-CSDN博客


 19-编译ffmpeg错误:ERROR: x264 not found using pkg-config

编译ffmpeg错误:ERROR: x264 not found using pkg-config-CSDN博客


20-Linux系统报错:Failed to execute default Terminal Emulator. Input/output error.

Linux系统报错:Failed to execute default Terminal Emulator. Input/output error.-CSDN博客


 21-Linux 环境下安装配置FFmpeg

Linux 环境下安装配置FFmpeg_linuxbianyianzhuangffmpeg-CSDN博客


22-丝滑解决ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29‘ not found问题

丝滑解决ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29‘ not found问题-CSDN博客


 23-Nvidia显卡Failed to initialize NVML Driver/library version mismatch错误解决方案

Nvidia显卡Failed to initialize NVML Driver/library version mismatch错误解决方案_driverlibrary version mismatch-CSDN博客


24-【报错解决方案】Error: mkl-service + Intel(R) MKL: MKL_THREADING_LAYER=INTEL is incompatible with libgomp-a3

这个报错需要再终端输入以下指令校准即可,亲测有效

export MKL_THREADING_LAYER=GNU

【报错解决方案】Error: mkl-service + Intel(R) MKL: MKL_THREADING_LAYER=INTEL is incompatible with libgomp-a3_shuf: write error: broken pipe shuf: write error e-CSDN博客


 25-ffmpeg: error while loading shared libraries: libopenh264.so.5: cannot open shared object file

# ffmpeg 3.4.1

conda install ffmpeg x264=20131218 -c conda-forge

# ffmpeg 4

conda install x264=='1!152.20180717' ffmpeg=4.0.2 -c conda-forge

ffmpeg: error while loading shared libraries: libopenh264.so.5: cannot open shared object file: No s-CSDN博客


 26-torchtext与torch版本对应关系,一文看懂

torchtext与torch版本对应关系,一文看懂_torch2.11对应的torchtext-CSDN博客

#【cuda:113, pip install torchtext==0.13】


 27-osgeo python安装入门实例

osgeo python安装入门实例_osgeo库安装-CSDN博客

conda install -c conda-forge gdal


 28-no module named ‘segmentation_models_pytorch.unet‘

no module named ‘segmentation_models_pytorch.unet‘_no module named segmentation models pytorch-CSDN博客

pip install segmentation-models-pytorch==0.1.0


 29-安装了GDAL,导入报错ModuleNotFoundError: No module named ‘_gdal‘

安装了GDAL,导入报错ModuleNotFoundError: No module named ‘_gdal‘_gdal安装成功但是不能导入-CSDN博客


 30-anaconda镜像出问题:Collecting package metadata (current_repodata.json): failed UnavailableInvalidChanne

conda Collecting package metadata (repodata.json)卡住或 failed问题_collecting package metadata (repodata.json):-CSDN博客

anaconda镜像出问题:Collecting package metadata (current_repodata.json): failed UnavailableInvalidChanne_collecting package metadata (repodata.json): faile-CSDN博客

清华源:

channels:

  - defaults

show_channel_urls: true

channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda

default_channels:

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2

custom_channels:

  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudchannels:

  - defaults

show_channel_urls: true

channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda

default_channels:

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2

custom_channels:

  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

 


31-"failed to execute PosixPath('dot'), make sure the Graphviz executables are on your systems" PATH on mac in sage math

"failed to execute PosixPath('dot'), make sure the Graphviz executables are on your systems" PATH on mac in sage math - Stack Overflow

What I do is to follow the instruction here to install graphviz (without root) and run 

conda install python-graphviz

. It is not wise to install everything under sudo.



网站公告

今日签到

点亮在社区的每一天
去签到