acoustic-van-30942
04/08/2023, 5:05 AMpytorch 1.13.0 with GPU on Metaflow?
I tried looking through this thread (https://github.com/Netflix/metaflow/issues/250), but didn't seem to work for me.
The batch job is using p2.xlargeacoustic-van-30942
04/08/2023, 5:07 AM@conda_base(
libraries={
"pytorch::pytorch": "1.13.0",
"pytorch::torchvision": "0.14.0",
"conda-forge::boto3": "1.26.107",
"conda-forge::pandas": "1.5.3",
"conda-forge::imageio": "2.27.0",
"conda-forge::torchmetrics": "0.10.2",
"conda-forge::future": "0.18.2",
"conda-forge::tensorboard": "2.8.0",
"conda-forge::pandas-profiling": "3.6.3",
"conda-forge::bidict": "0.22.1",
"conda-forge::matplotlib": "3.1",
"conda-forge::python-graphviz": "0.20.1",
"conda-forge::torch-scatter": "2.1.1"
},
python="3.10.1",
)
class GWFlow(FlowSpec):
@step
def start(self):
"""
This is the start of the flow
"""
self.next(self.train)
@enable_decorator(batch(gpu=1, memory=20000), flag=os.getenv("EN_BATCH"))
@environment(
vars={
"EN_BATCH": os.getenv("EN_BATCH"),
"NVIDIA_DRIVER_CAPABILITIES": "compute,utility",
"CUDA_VISIBLE_DEVICES": "0,1"
}
)
@step
def train(self):
import torch
import sys
import os
from subprocess import call
# Use cmd to check nvidia card
print(os.popen("nvidia-smi").read())
print('__Devices')
call(["nvidia-smi", "--format=csv",
"--query-gpu=index,name,driver_version,memory.total,memory.used,memory.free"])
print(os.popen("nvcc --version").read())
# See if pytorch picks up the GPUs
print('__Python VERSION:', sys.version)
print('__pyTorch VERSION:', torch.__version__)
print('__CUDA VERSION', torch.version.cuda)
print('__CUDNN VERSION:', torch.backends.cudnn.version())
print('__Is CUDA available:', torch.cuda.is_available())
print('__Number CUDA Devices:', torch.cuda.device_count())
print('Active CUDA Device: GPU', torch.cuda.current_device())
print('Available devices ', torch.cuda.device_count())
print('Current cuda device ', torch.cuda.current_device())
print(f"GPU count: {torch.cuda.device_count()}")
The print output of the flow:victorious-lawyer-58417
04/08/2023, 5:46 AMacoustic-van-30942
04/09/2023, 3:10 AMpytorch
2023-04-08 19:50:24.819 [84/train/431 (pid 11834)] [5e030a58-8074-485d-bff4-734b7918f67c] [GCC 7.3.0]
2023-04-08 19:50:24.820 [84/train/431 (pid 11834)] [5e030a58-8074-485d-bff4-734b7918f67c] __pyTorch VERSION: 1.11.0
2023-04-08 19:50:24.820 [84/train/431 (pid 11834)] [5e030a58-8074-485d-bff4-734b7918f67c] __CUDA VERSION 11.3
2023-04-08 19:50:24.820 [84/train/431 (pid 11834)] [5e030a58-8074-485d-bff4-734b7918f67c] __CUDNN VERSION: 8200
2023-04-08 19:50:24.819 [84/train/431 (pid 11834)] [5e030a58-8074-485d-bff4-734b7918f67c] /bin/sh: 1: nvcc: not found
2023-04-08 19:50:27.876 [84/train/431 (pid 11834)] [5e030a58-8074-485d-bff4-734b7918f67c] __Is CUDA available: True
2023-04-08 19:50:27.876 [84/train/431 (pid 11834)] [5e030a58-8074-485d-bff4-734b7918f67c] __Number CUDA Devices: 1
2023-04-08 19:49:42.614 [84/train/430 (pid 11833)] [3be30e2c-d339-4166-b6c5-138336b147a4] Active CUDA Device: GPU 0
2023-04-08 19:49:42.614 [84/train/430 (pid 11833)] [3be30e2c-d339-4166-b6c5-138336b147a4] Available devices 1
2023-04-08 19:49:42.615 [84/train/430 (pid 11833)] [3be30e2c-d339-4166-b6c5-138336b147a4] Current cuda device 0
2023-04-08 19:49:42.615 [84/train/430 (pid 11833)] [3be30e2c-d339-4166-b6c5-138336b147a4] GPU count: 1
2023-04-08 19:51:10.531 [84/train/430 (pid 11833)] [3be30e2c-d339-4166-b6c5-138336b147a4] Task finished with exit code 0.victorious-lawyer-58417
04/09/2023, 5:10 AMacoustic-van-30942
04/09/2023, 5:31 AM