
๐ค Tech Enthusiast | Robotics Maverick ๐ | Computer Vision ๐๏ธ
Diving into the realm of robots ๐ค, I'm a multi-hatted professional weaving together the intricate threads of data engineering, computer vision, machine learning, and software development. With a primary focus on the captivating world of computer vision, I'm on a mission to decipher visual data and breathe life into intelligent machines.
๐ Exploring pixels to unlock hidden insights. ๐ก Transforming raw data into meaningful experiences. ๐ค Collaborating with machines to bridge the physical and digital realms.
Join me on this exhilarating journey as I unravel the mysteries of vision, code, and innovation in the captivating landscape of robotics. Let's push the boundaries of what's possible, one pixel at a time! ๐
Pytorch, an open-source ML library, is popular among researchers due to its dynamic computing graph and efficient GPU acceleration. The heart of the Pytorch lies in its tensor library, which is the foundation of neural networks.
Docker
In the world of modern software development, Docker has emerged as a transformative technology that simplifies the development and management of applications.
Docker installation link below:
https://docs.docker.com/engine/install/
Dockerfile
The Dockerfile is a script that instructs Docker on how to build a container image. It specifies the base image, set up the environment, copies files, installs dependencies, and configures runtime settings.
Here's a breakdown of the key concept in a Dockerfile that is needed in setting up Pytorch.
Base Image: Choose a base image that provides the foundation of the container. It could be a minimal OS, a programing language, or a framework like pytorch which we will use.
RUN: The RUN instruction in a Dockerfile is used to execute commands during the image build process. It is typically employed to install packages, setup dependencies, and perform any necessary configuration.
WORKDIR: The WORKDIR instruction sets the working directory for any subsequent instructions in the Dockerfile.
CMD: The CMD instruction specifies the default command to run when a container is started from the image.
#Use latest pytorch base image
FROM pytorch/pytorch:latest
#Upgrade pip
RUN pip install --upgrade pip
#install essential libraries
RUN pip install numpy pandas opencv-python
#Setting the default working directory
WORKDIR /app
#Run a command in the background that will keep container running
CMD while true;do echo "Hello,world!"; sleep 1; done
docker-compose.yaml
While the Dockerfile defines a single container, the docker0compoase.yaml file enables you to define and manage multi-container applications. Let's write a compose file.
Services: Define each service(container) you want to run as a separate section in the file.
pytorch-container defines a service name built from the Dockerfile.
build section specifies the build context, which is the directory containing the Dockerfile and any resource needed during the build process.
dockerfile: Specifies the name of the Dockerfile to use for building the image.
ports: Maps port 8080 on the host to port 8080 on the container for the service. This allows you to access the web application running the docker via 'http://localhost:8080'
volumes: ./ copy all the files in the docker-compose.yaml on the host into the /app directory in the pytorch-container. This allows you to make changes to the code on your local machine and have them immediately reflected in the container.
version : '3'
services:
pytorch-container:
build:
context: .
dockerfile: Dockerfile
ports:
- 8080:8080
volumes:
- ./:/app
Build the docker image
sudo docker-compose up --build
Execute the docker-compose.yaml
sudo docker exec -it pytorch-container bash
