Skip to content

Instantly share code, notes, and snippets.

@Ravi2712
Last active October 23, 2024 22:28
Show Gist options
  • Select an option

  • Save Ravi2712/47f070a6578153d3caee92bb67134963 to your computer and use it in GitHub Desktop.

Select an option

Save Ravi2712/47f070a6578153d3caee92bb67134963 to your computer and use it in GitHub Desktop.
Install Pytorch with virtualenv

Create requirements.txt file & add some required libraries to install via pip

opencv-python
numpy
Pillow
matplotlib
tqdm

Getting Started

(1) Check if pip is installed:

$ pip --version

#If `pip` is not installed, follow steps below:
$ cd ~
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
$ python3 get-pip.py

(2) Install virtual environment first & then activate:

$ cd <project-directory>
$ python3 -m pip install --user virtualenv #Install virtualenv if not installed in your system
$ python3 -m virtualenv env #Create virtualenv for your project
$ source env/bin/activate #Activate virtualenv for linux/MacOS
$ env\Scripts\activate #Activate virtualenv for Windows

(3) Install torch via pip by running following command (If possible always install torch via stable wheel they provide: https://pytorch.org/):

$ pip install torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html

(4) Install all dependencies for your project from requirements.txt file:

$ pip install -r requirements.txt
@OneWorld-github

OneWorld-github commented May 30, 2020

Copy link
Copy Markdown

Hi Jay, thanks for the post here.

Can you include the version of Python you used, and graphics card and graphics card drivers used ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment