Refactor dockerfile (#149)
* refactor dockerfile to allow mounting * update README.md
This commit is contained in:
1 parent
70ab061f75
commit
362a4beebb
2 files changed
+16
-11
No files matched your search
+9
-8
@@ -1,22 +1,23 @@
|
|||||||
# Build: docker build -t project_name .
|
# Build: docker build -t project_name .
|
||||||
# Run: docker run --gpus all -it --rm project_name
|
# Run: docker run -v $(pwd):/workspace/project --gpus all -it --rm project_name
|
||||||
|
|
||||||
# Build from official Nvidia PyTorch image
|
# Build from official Nvidia PyTorch image
|
||||||
# GPU-ready with Apex for mixed-precision support
|
# GPU-ready with Apex for mixed-precision support
|
||||||
# https://ngc.nvidia.com/catalog/containers/nvidia:pytorch
|
# https://ngc.nvidia.com/catalog/containers/nvidia:pytorch
|
||||||
# https://docs.nvidia.com/deeplearning/frameworks/support-matrix/
|
# https://docs.nvidia.com/deeplearning/frameworks/support-matrix/
|
||||||
FROM nvcr.io/nvidia/pytorch:21.03-py3
|
FROM nvcr.io/nvidia/pytorch:21.05-py3
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
# Copy all files
|
|
||||||
ADD . /workspace/project
|
|
||||||
WORKDIR /workspace/project
|
WORKDIR /workspace/project
|
||||||
|
|
||||||
|
|
||||||
# Create myenv
|
# Copy files to create conda environment
|
||||||
RUN conda env create -f conda_env_gpu.yaml -n myenv
|
COPY conda_env_gpu.yaml requirements.txt ./
|
||||||
RUN conda init bash
|
|
||||||
|
|
||||||
|
|
||||||
|
# Create myenv
|
||||||
|
RUN conda env create -f conda_env_gpu.yaml -n myenv \
|
||||||
|
&& conda init bash
|
||||||
|
|
||||||
# Set myenv to default virtual environment
|
# Set myenv to default virtual environment
|
||||||
RUN echo "source activate myenv" >> ~/.bashrc
|
RUN echo "source activate myenv" >> ~/.bashrc
|
||||||
@@ -364,10 +364,14 @@ python run.py -m 'experiment=glob(*)'
|
|||||||
|
|
||||||
## 🐳 Docker
|
## 🐳 Docker
|
||||||
I recommend the official [nvidia ngc pytorch container](https://ngc.nvidia.com/catalog/containers/nvidia:pytorch/tags).
|
I recommend the official [nvidia ngc pytorch container](https://ngc.nvidia.com/catalog/containers/nvidia:pytorch/tags).
|
||||||
|
|
||||||
To build the container from provided Dockerfile use:
|
To build the container from provided Dockerfile use:
|
||||||
```yaml
|
```bash
|
||||||
docker build -t project_name .
|
docker build -t <project_name> .
|
||||||
docker run --gpus all -it --rm project_name
|
```
|
||||||
|
To mount the project to the container use:
|
||||||
|
```bash
|
||||||
|
docker run -v $(pwd):/workspace/project --gpus all -it --rm <project_name>
|
||||||
```
|
```
|
||||||
|
|
||||||
Others dockerfiles are provided on branch [`dockerfiles`](https://github.com/ashleve/lightning-hydra-template/tree/dockerfiles). You can use them as a starting point for building more complicated images.
|
Others dockerfiles are provided on branch [`dockerfiles`](https://github.com/ashleve/lightning-hydra-template/tree/dockerfiles). You can use them as a starting point for building more complicated images.
|
||||||
|
|||||||
Reference in new issue
Block a user