参考链接:
SteganoGAN 项目运行过程

SteganoGAN 项目复现

实验室配置

  • 服务器显卡 RTX 3090 ;内存 62G
  • CUDA 11.2
  • Ubuntu 18.04

开发环境:vscode + python 3.7.0


修改pip源的方法,用everything搜pip.ini进行修改
可选的pip源链接如下:

国内的镜像源
阿里云 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
清华大学 -i  https://pypi.tuna.tsinghua.edu.cn/simple/
国外默认源
默认源 -i https://pypi.org/simple

报错整理

  1. 错误提示
    RuntimeError: CUDA out of memory. Tried to allocate 288.00 MiB (GPU 0; 23.70 GiB total capacity; 2.01 GiB already allocated; 223.56 MiB free; 2.02 GiB reserved in total by PyTorch)
    GPU进程占满了
    解决方案
    在Xshell中输入watch -n 1 nvidia-smi或者nvidia-smi,查看占用GPU的进程
    然后输入sudo kill PID(进程号)

  2. 错误提示
    cuDNN error: CUDNN_STATUS_EXECUTION_FAILED
    可能是因为CUDA和显卡驱动不对应,我重装了显卡驱动,安装了cuDNN,更新了torch和几个库(别的操作不记得了),解决了
    参考链接
    ubuntu安装 anaconda3+cuda11.2+cuDNN+pytorch1.7 这个写的比较详细

  3. 错误提示
    decode时报错,提示bits为bool类型的list,无法转为int类型
    解决方案
    在utils.py中添加下图红框中三行代码(感谢邢同学)
    utils.py修改

  4. 报错:AttributeError: module 'PIL.TiffTags' has no attribute 'IFD'
    解决方案 :更新pillow包到7.1.2 pillow的下载地址

成功运行,但是decode方法中没写输出message,自己在models.py里加一行
print(candidate)就行 (2022.1.4补充:其实命令行有输出,只是之前应该没有解码成功所以没有)
如图

运行结果


虚拟环境导出

通过pip导出虚拟环境
pip freeze>requirements.txt
在新虚拟环境中安装requirements.txt中包列表:
pip install -r requirements.txt

服务器的虚拟环境如下:python 3.7.0

Package Version

argcomplete 1.12.3
backcall 0.2.0
backports.functools-lru-cache 1.6.4
debugpy 1.5.1
decorator 5.1.0
entrypoints 0.3
flake8 4.0.1
imageio 2.4.1
importlib-metadata 4.2.0
ipykernel 6.6.0
ipython 7.30.1
jedi 0.18.1
jupyter-client 7.1.0
jupyter-core 4.9.1
matplotlib-inline 0.1.3
mccabe 0.6.1
mkl-fft 1.3.1
mkl-random 1.2.2
mkl-service 2.4.0
nest-asyncio 1.5.4
numpy 1.21.4
olefile 0.46
parso 0.8.3
pexpect 4.8.0
pickleshare 0.7.5
Pillow 7.1.2
pip 21.3.1
prompt-toolkit 3.0.23
ptyprocess 0.7.0
pycodestyle 2.8.0
pyflakes 2.4.0
Pygments 2.10.0
python-dateutil 2.8.2
pyzmq 22.3.0
reedsolo 0.3
scipy 1.1.0
setuptools 59.4.0
six 1.16.0
steganogan 0.1.3
torch 1.7.1
torchaudio 0.7.0a0+a853dff
torchvision 0.8.2
tornado 6.1
tqdm 4.62.3
traitlets 5.1.1
typing_extensions 4.0.1
wcwidth 0.2.5
wheel 0.37.0
yapf 0.31.0
zipp 3.6.0


2022.6.17 更新
Windows电脑上会报错,但ubuntu可以用下面评论中上传的模型跑通
跑通的环境如下

backcall==0.2.0
certifi==2022.5.18.1
debugpy==1.6.0
decorator==5.1.1
entrypoints==0.4
imageio==2.4.1
ipykernel==6.9.1
ipython==7.34.0
jedi==0.18.1
jupyter-client==7.3.4
jupyter-core==4.10.0
matplotlib-inline==0.1.3
nest-asyncio==1.5.5
numpy==1.21.6
parso==0.8.3
pexpect==4.8.0
pickleshare==0.7.5
Pillow==6.2.2
prompt-toolkit==3.0.29
ptyprocess==0.7.0
Pygments==2.12.0
python-dateutil==2.8.2
pyzmq==23.1.0
reedsolo==0.3
scipy==1.1.0
six==1.16.0
steganogan==0.1.3
torch==1.7.1
torchvision==0.2.1
tornado==6.1
tqdm==4.64.0
traitlets==5.3.0
typing_extensions==4.2.0
wcwidth==0.2.5
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐