Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.1%) to scientific vocabulary
Keywords
Repository
Docker | PyTorch
Basic Info
- Host: GitHub
- Owner: scape-agency
- License: cc-by-sa-4.0
- Language: Shell
- Default Branch: main
- Homepage: https://hub.docker.com/repository/docker/scapeagency/pytorch/general
- Size: 89.8 KB
Statistics
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
- Releases: 0
Topics
Metadata Files
README.md
Docker | PyTorch
When setting up a Docker image for PyTorch that supports both CPU and GPU, you'll need to include the necessary dependencies and configurations for both processing types. Here’s a basic setup you can use to create a Docker image that supports PyTorch on both CPU and GPU:
Base Image: Start with an official PyTorch image from the NVIDIA container repository, which comes with CUDA and cuDNN pre-installed, ensuring GPU support.
Requirements: Install any additional packages you need for your specific project.
Environment: Set up the correct environment variables and ensure that the container can dynamically switch between CPU and GPU based on the available hardware.
Here is a simple example of a Dockerfile:
```dockerfile
Use an official PyTorch image as a parent image
FROM pytorch/pytorch:1.12.0-cuda11.3-cudnn8-runtime
Install any needed packages specified in requirements.txt
COPY requirements.txt /tmp/ RUN pip install --requirement /tmp/requirements.txt
Run the application
CMD ["python", "./src/my_script.py"] ```
Key Notes:
- PyTorch Version: Replace
1.12.0-cuda11.3-cudnn8-runtimewith the version of PyTorch that matches your requirements. - CUDA/cuDNN: The CUDA and cuDNN versions need to match the ones required by the specific PyTorch version.
- requirements.txt: This file should contain all the Python packages you need. Copy this into your Docker image and install them.
To build and run the Docker container:
- Build the Image:
docker build -t my-pytorch-app . - Run the Container:
- On CPU:
docker run my-pytorch-app - On GPU:
docker run --gpus all my-pytorch-app
- On CPU:
This setup ensures that your Docker container can utilize GPU resources when available, falling back to CPU when GPUs are not accessibl
To set up a Docker image based on Ubuntu for PyTorch that supports both CPU and GPU usage, you'll start with an Ubuntu base image and manually install the necessary components like Python, PyTorch, CUDA, and cuDNN. This approach gives you more control over the versions and the setup.
Here’s a detailed Dockerfile to achieve this:
```dockerfile
Use an Ubuntu base image
FROM ubuntu:20.04
Avoid prompts during package installation
ARG DEBIAN_FRONTEND=noninteractive
Install basic utilities
RUN apt-get update && apt-get install -y \ wget \ curl \ git \ python3-pip \ python3-dev \ build-essential
Link python3 to python
RUN ln -s /usr/bin/python3 /usr/bin/python
Upgrade pip
RUN pip3 install --upgrade pip
Install PyTorch with CUDA support
RUN pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113
Copy the requirements file and install Python dependencies
COPY requirements.txt /tmp/ RUN pip3 install -r /tmp/requirements.txt
Set the working directory
WORKDIR /app
Copy the rest of your application's code
COPY . /app
Command to run on container start
CMD ["python", "app.py"] ```
Explanation:
- Base Image: Starts with Ubuntu 20.04.
- Utilities: Installs essential packages like
wget,curl,git, and Python-related tools. - Python Link: Makes
pythoncommand available by linkingpython3topython. - Python and PyTorch: Installs Python packages and PyTorch with CUDA 11.3 support.
- Requirements: Installs additional Python dependencies from a
requirements.txtfile. - Working Directory and Application Code: Sets the working directory and copies your application code into the image.
Building and Running the Docker Container:
- Build the Image:
docker build -t my-pytorch-app . - Run the Container:
- On CPU:
docker run my-pytorch-app - On GPU:
docker run --gpus all my-pytorch-app
- On CPU:
This Dockerfile ensures that the application can utilize GPU acceleration when available, and will work on CPUs otherwise. Adjust the CUDA version in the PyTorch installation command according to the CUDA version compatible with your GPU drivers.
Owner
- Name: Scape Agency
- Login: scape-agency
- Kind: organization
- Email: info@scape.agency
- Location: Amsterdam, Netherlands
- Website: https://www.scape.agency
- Twitter: scape_agency
- Repositories: 5
- Profile: https://github.com/scape-agency
Future Horizons into View Today
Citation (CITATION.cff)
cff-version: 1.2.0
title: Scape Agency - Docker Images - PyTorch
version: 0.0.1
date-released: 2024-07-01
url: "https://github.com/scape-agency/docker-pytorch"
message: >-
If you use this software, please cite it using
the metadata from this file.
type: software
authors:
- given-names: Lars Bastiaan
family-names: van Vianen
email: lars@scape.agency
affiliation: Scape Agency
orcid: 'https://orcid.org/0000-0002-8790-8630'
GitHub Events
Total
- Push event: 2
Last Year
- Push event: 2
Dependencies
- actions/checkout v3 composite
- docker/bake-action v2 composite
- docker/login-action v2 composite
- docker/metadata-action v4 composite
- docker/setup-buildx-action v2 composite
- docker/setup-qemu-action v2 composite
- ubuntu 24.04 build
- scapeagency/swing-devcontainer latest build
- ubuntu 20.04 build
- pytest ^6.2 develop
- matplotlib ^3.4
- numpy ^1.21
- pandas ^1.3
- python ^3.8
- torch *
- torchaudio *
- torchvision *