小编김승수*_*김승수的帖子

即使 Pytorch 检测到 GPU 也没有使用 GPU

我将 Windows 10 jupyter 笔记本作为服务器并在其上运行一些火车。

我已经正确安装了 CUDA 9.0 和 cuDNN,并且 python 检测到了 GPU。这就是我在 anaconda 提示符下得到的内容。

>>> torch.cuda.get_device_name(0)
'GeForce GTX 1070'
Run Code Online (Sandbox Code Playgroud)

我还通过 .cuda() 将模型和张量放在 cuda 上

model = LogPPredictor(1, 58, 64, 128, 1, 'gsc')

if torch.cuda.is_available():
    torch.set_default_tensor_type(torch.cuda.DoubleTensor)
    model.cuda()
else:
    torch.set_default_tensor_type(torch.FloatTensor)

list_train_loss = list()
list_val_loss = list()
acc = 0
mse = 0

optimizer = args.optim(model.parameters(),
                       lr=args.lr,
                       weight_decay=args.l2_coef)

data_train = DataLoader(args.dict_partition['train'], 
                        batch_size=args.batch_size,
                        pin_memory=True,
                        shuffle=args.shuffle)

data_val = DataLoader(args.dict_partition['val'],
                     batch_size=args.batch_size,
                     pin_memory=True,
                     shuffle=args.shuffle)

for epoch in tqdm_notebook(range(args.epoch), desc='Epoch'):
    model.train()
    epoch_train_loss = 0
    for i, batch …
Run Code Online (Sandbox Code Playgroud)

python gpu pytorch

5
推荐指数
1
解决办法
4561
查看次数

.ebextensions 中的命令在 ElasticBeanstalk 上失败

我正在尝试使用 AWS CodePipeline 将 Node.js 应用程序部署到 AWS ElasticBeanstalk。由于我的应用程序使用 WebSockets,因此我在.ebextensions.

container_commands:
  enable_websocket:
    command: 
      sed -i '/\s*proxy_set_header\s*Connection/c \
              proxy_set_header Upgrade $http_upgrade;\
              proxy_set_header Connection "upgrade";\
          ' /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf
Run Code Online (Sandbox Code Playgroud)

但是,CodePipeline 在部署过程中失败,ElasticBeanstalk 日志文件cfn-init.log显示如下:

2020-06-18 12:43:42,345 [INFO] -----------------------Starting build-----------------------
2020-06-18 12:43:42,352 [INFO] Running configSets: Infra-EmbeddedPostBuild
2020-06-18 12:43:42,355 [INFO] Running configSet Infra-EmbeddedPostBuild
2020-06-18 12:43:42,359 [INFO] Running config postbuild_0_drcha
2020-06-18 12:43:42,381 [ERROR] Command enable_websockets (sed -i '/\s*proxy_set_header\s*Connection/c \
        proxy_set_header Upgrade $http_upgrade;\
        proxy_set_header Connection "upgrade";\
        ' /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf) failed
2020-06-18 12:43:42,381 [ERROR] Error encountered during build of …
Run Code Online (Sandbox Code Playgroud)

nginx amazon-web-services amazon-elastic-beanstalk

4
推荐指数
2
解决办法
4111
查看次数