自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(10)
  • 收藏
  • 关注

原创 RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #2 ‘target‘

在使用CrossEntropyLoss()函数时,引发上述错误,大致意思是数据类型不匹配,CrossEntropyLoss()要求输入数据应为long型,但是我的数据必须是float类型的,所以只能改用MSELoss()函数,保持两个输入向量size一致即可。 ...

2022-04-20 18:37:03 2781 1

原创 -bash: activate:No such file/

没有activate相关文件,无法激活虚拟环境 解决方案:添加进去 export PATH="~/miniconda3/bin:$PATH"

2021-08-15 14:12:51 1025

原创 Missing key(s) in state_dict:

今天调试代码的时候发现一个错误: Missing key(s) in state_dict: 错误代码: model.bert.load_state_dict(torch.load(args.init_checkpoint, map_location="cpu")) 解决方案: model.load_state_dict(torch.load(args.init_checkpoint), False) ...

2021-08-13 18:18:05 1529

原创 查看tensorflow环境下的GPU是否可以用

print(tf.test.is_gpu_available())

2021-08-10 15:43:19 380

转载 将tensorflow版本的.ckpt模型转成pytorch的.bin模型

转载自https://www.cnblogs.com/cxq1126/p/14277134.html 如上图,将bert_model.ckpt文件转化成pytorch_model.bin文件 可以自己创建一个文件convert.py,复制以下代码,修改一下路径名称即可。 from __future__ import absolute_import from __future__ import division from __future__ import print_function import ar

2021-04-13 10:41:52 1396

原创 安装tensorflow镜像

链接:https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/tensorflow-gpu/ 在命令行中输入:python -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-gpu==2.2.1

2021-04-02 21:14:52 1052

原创 python中list,tensor,array相互转化

list转化为array array=numpy.array(list) array转化为list list=numpy.list() tensor转化为list list=tensor.numpy().tolist() list转化为tensor tensor=torch.Tensor(list) array转化为tensor tensor=torch.from_numpy(array) tensor转化为array array=tensor.numpy() array=tenor.cpu().numpy

2021-03-23 09:49:07 3316 2

原创 RuntimeError: CUDA out of memory. Tried to allocate 20.00 MiB (GPU 0; 11.17 GiB total capacity; 1.10

服务器上跑程序,出现这种错误,大概是因为程序太大内存不够,有以下两种解决方式: 1、batch_size设置太大,改小一点 2、cuda节点被占用,可以指定其他节点,一种方式:程序里面写device = torch.device(‘cuda:0’ if torch.cuda.is_available() else ‘cpu’),服务器里面写CUDA_VISIBLE_DEVICES=X;另一种方式:程序里面直接写os.environ[“CUDA_VISIBLE_DEVICES”] = “2,3” ...

2021-03-17 13:32:36 3414 1

原创 terminate called after throwing an instance of ‘std::runtime_error‘

terminate called after throwing an instance of ‘std::runtime_error’ 运行pytorch程序报错: terminate called after throwing an instance of ‘std::runtime_error’ what(): NCCL Error 1: unhandled cuda error 解决方法: 我之前下载的pytorch版本是1.4的,后来换成1.0.1的就好了 ...

2021-03-14 18:56:01 1585

原创 服务器常用指令

服务器常用指令查看当前GPU的占用情况创建虚拟环境进入虚拟环境退出虚拟环境查看当前存在哪些虚拟环境查看指定用户是否占用GPU查看CUDA版本指定GPU版本 查看当前GPU的占用情况 nvidia-smi 创建虚拟环境 conda create -n your_env_name python=X.X(2.7、3.6等) 进入虚拟环境 source activate xxx 退出虚拟环境 source deactivate xxx 查看当前存在哪些虚拟环境 conda env list 查看指定用户是否占用GP

2021-02-18 22:42:31 368

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除