I am trying to make a classification docker container, but here i am putting a short code. The issue is that docker is not able to take the image folder as input. Here is Dockerfile
FROM pytorch/pytorch:1.6.0-cuda10.1-cudnn7-runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
# we have found python3.7 in base docker
python3-pip \
python3-setuptools \
build-essential \
&& \
apt-get clean && \
python -m pip install --upgrade pip
WORKDIR /workspace
COPY inference.py /workspace
ENTRYPOINT ["python", "inference.py"]
Here is inference.py file
from glob import glob
import torch
import os
print(os.getcwd())
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-i", '--input_folder', required=True)
args = parser.parse_args()
#load data
images = sorted(glob("{}/*.nii.gz".format(args.input_folder)))
data_dicts = [
{"image": image_name}
for image_name in images
]
print('number of images',len(data_dicts))
print(torch.cuda.get_device_name(0))
if __name__ == "__main__":
main()
Using build command i build docker image
docker build -t test .
This is how i am running
docker run --gpus all test -i=images
The folder images is in current directoy. What i am expecting to print the number of images.
When i run the image using docker run --gpus all test -i images it print following
/workspace
number of images 0
NVIDIA GeForce GTX 1060