add conda env file
This commit is contained in:
1 parent
3e67b5300c
commit
8d55f151bd
10 files changed
+82
-51
No files matched your search
@@ -229,5 +229,3 @@ project/data/
|
||||
project/lightning_logs/
|
||||
project/wandb/
|
||||
project/logs/
|
||||
|
||||
project/project_config.yaml
|
||||
@@ -4,8 +4,19 @@ A convenient starting template for most deep learning projects. Built with <b>Py
|
||||
|
||||
|
||||
## Setup
|
||||
Read [SETUP.md](SETUP.md)
|
||||
<br><br>
|
||||
Read [SETUP.md](SETUP.md) for more info or just do this quick setup:
|
||||
```
|
||||
git clone https://github.com/kinoai/hackathon-template
|
||||
cd hackathon-template
|
||||
conda update conda
|
||||
conda env create -f conda_env.yml -n hack_env
|
||||
conda activate hack_env
|
||||
pip install -r requirements.txt
|
||||
wandb login
|
||||
cd project
|
||||
python train.py
|
||||
```
|
||||
<br>
|
||||
|
||||
|
||||
## Project structure
|
||||
@@ -50,7 +61,8 @@ The directory structure of new project looks like this:
|
||||
└── requirements.txt
|
||||
```
|
||||
|
||||
## Project config parameters ([project_config.yaml](project/project_config.yaml))
|
||||
|
||||
## Project config parameters ([project_config.yaml](project/project_config.yml))
|
||||
```yaml
|
||||
num_of_gpus: -1
|
||||
|
||||
@@ -89,7 +101,8 @@ printing:
|
||||
profiler: False
|
||||
```
|
||||
|
||||
## Run config parameters ([run_configs.yaml](project/run_configs.yaml))
|
||||
|
||||
## Run config parameters ([run_configs.yaml](project/run_configs.yml))
|
||||
You can store many run configurations in this file.<br>
|
||||
Example run configuration:
|
||||
```yaml
|
||||
@@ -116,10 +129,17 @@ MNIST_CLASSIFIER_V1:
|
||||
num_workers: 4
|
||||
pin_memory: True
|
||||
```
|
||||
The run configuration that you want to train with needs to be chosen in [train.py](project/train.py):
|
||||
To run training pass run config name as an argument:
|
||||
```
|
||||
python train.py -c MNIST_CLASSIFIER_V1
|
||||
python train.py --conf_name MNIST_CLASSIFIER_V1
|
||||
```
|
||||
Or modify default run config name in [train.py](project/train.py):
|
||||
```python
|
||||
if __name__ == "__main__":
|
||||
RUN_CONFIG_NAME = "MNIST_CLASSIFIER_V1"
|
||||
main(run_config_name=RUN_CONFIG_NAME)
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument("-c", "--conf_name", type=str, default="MNIST_CLASSIFIER_V1")
|
||||
args = parser.parse_args()
|
||||
|
||||
main(run_config_name=args.conf_name)
|
||||
```
|
||||
@@ -1,48 +1,54 @@
|
||||
## Setup
|
||||
1. Install anaconda if you don't already have it
|
||||
|
||||
#### 1. Install anaconda
|
||||
https://docs.conda.io/projects/conda/en/latest/user-guide/install/download.html
|
||||
|
||||
#### 2. Create anaconda env
|
||||
2. Clone repo
|
||||
```
|
||||
conda create --name hack_env
|
||||
git clone https://github.com/kinoai/hackathon-template
|
||||
cd hackathon-template
|
||||
```
|
||||
3. Create conda environment (change 'hack_env' to any name you want)
|
||||
```
|
||||
conda update conda
|
||||
conda env create -f conda_env.yml -n hack_env
|
||||
conda activate hack_env
|
||||
```
|
||||
|
||||
#### 3. Make sure proper python PATH is loaded
|
||||
Unix
|
||||
4. Make sure proper python PATH is loaded<br>
|
||||
- Unix
|
||||
```
|
||||
which python
|
||||
```
|
||||
Windows
|
||||
- Windows
|
||||
```
|
||||
for %i in (python.exe) do @echo. %~$PATH:i
|
||||
```
|
||||
Expected result: `PATH_TO_CONDA/envs/ENV_NAME/bin/python`
|
||||
|
||||
#### 4. Install pytorch with conda
|
||||
Installation command generator: https://pytorch.org/get-started/locally/
|
||||
5. Install requirements
|
||||
```
|
||||
conda install pytorch torchvision torchaudio cudatoolkit=11.0 -c pytorch
|
||||
```
|
||||
|
||||
#### 5. Clone repo
|
||||
```
|
||||
git clone https://github.com/kinoai/hackathon-template
|
||||
```
|
||||
|
||||
#### 6. Install requirements with pip
|
||||
```
|
||||
cd hackathon-template
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
#### 7. Log into your wandb account
|
||||
6. Log to your Weights&Biases account
|
||||
```
|
||||
wandb login
|
||||
```
|
||||
7. Run training
|
||||
```
|
||||
cd project
|
||||
python train.py
|
||||
```
|
||||
<br>
|
||||
|
||||
#### 8. PyCharm setup
|
||||
|
||||
#### Important notes!
|
||||
- If you are not using GPU (CUDA incompatible GPU) you may need to specify the number of GPUs manually instead of leaving the default `-1` in `project_config.yaml`:
|
||||
```
|
||||
num_of_gpus: 0
|
||||
```
|
||||
<br>
|
||||
|
||||
|
||||
## PyCharm setup
|
||||
- open this repository as PyCharm project
|
||||
- set "hack_env" as project interpreter:<br>
|
||||
`Ctrl + Shift + A -> type "Project Interpreter"`
|
||||
@@ -52,11 +58,3 @@ Installation command generator: https://pytorch.org/get-started/locally/
|
||||
`Ctrl + Shift + A -> type "Edit Configurations..." -> select "Emulate terminal in output console"`
|
||||
- run training:<br>
|
||||
`right click on train.py file -> "Run 'train'"`
|
||||
|
||||
|
||||
|
||||
#### Important notes!
|
||||
- If you are not using GPU (CUDA incompatible GPU) you may need to specify the number of GPUs manually instead of leaving the default `-1` in `config.yaml`:
|
||||
```
|
||||
num_of_gpus: 0
|
||||
```
|
||||
@@ -0,0 +1,13 @@
|
||||
#name: hack_env
|
||||
channels:
|
||||
- pytorch
|
||||
- conda-forge
|
||||
- defaults
|
||||
dependencies:
|
||||
- python=3.8
|
||||
- pip
|
||||
- cudatoolkit
|
||||
- pytorch
|
||||
- torchvision
|
||||
- torchaudio
|
||||
#prefix: C:\Users\UserX\Anaconda3\envs\hack_env
|
||||
File renamed without changes.
File renamed without changes.
+8
-5
@@ -1,4 +1,5 @@
|
||||
from pytorch_lightning.profiler import SimpleProfiler
|
||||
from argparse import ArgumentParser
|
||||
import yaml
|
||||
|
||||
# utils
|
||||
@@ -7,7 +8,6 @@ from utils.callbacks import *
|
||||
|
||||
|
||||
def train(project_config, run_config):
|
||||
|
||||
# Init PyTorch Lightning model ⚡
|
||||
lit_model = init_lit_model(hparams=run_config["model"])
|
||||
|
||||
@@ -83,13 +83,16 @@ def load_config(path):
|
||||
|
||||
def main(run_config_name):
|
||||
# Load configs
|
||||
project_config = load_config("project_config.yaml")
|
||||
run_config = load_config("run_configs.yaml")[run_config_name]
|
||||
project_config = load_config("project_config.yml")
|
||||
run_config = load_config("run_configs.yml")[run_config_name]
|
||||
|
||||
# Train model
|
||||
train(project_config=project_config, run_config=run_config)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
RUN_CONFIG_NAME = "MNIST_CLASSIFIER_V2"
|
||||
main(run_config_name=RUN_CONFIG_NAME)
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument("-c", "--conf_name", type=str, default="MNIST_CLASSIFIER_V1")
|
||||
args = parser.parse_args()
|
||||
|
||||
main(run_config_name=args.conf_name)
|
||||
@@ -137,8 +137,8 @@ class SaveCodeToWandbCallback(pl.Callback):
|
||||
"utils/callbacks.py",
|
||||
"utils/init_utils.py",
|
||||
"train.py",
|
||||
"project_config.yaml",
|
||||
"run_configs.yaml",
|
||||
"project_config.yml",
|
||||
"run_configs.yml",
|
||||
]
|
||||
self.model_path = os.path.dirname(inspect.getfile(lit_model.__class__))
|
||||
self.datamodule_path = os.path.dirname(inspect.getfile(datamodule.__class__))
|
||||
|
||||
@@ -8,8 +8,8 @@ import train
|
||||
RUN_CONFIG_NAME = "MNIST_CLASSIFIER_V1"
|
||||
|
||||
# Load configs
|
||||
project_config = train.load_config("../project_config.yaml")
|
||||
run_config = train.load_config("../run_configs.yaml")[RUN_CONFIG_NAME]
|
||||
project_config = train.load_config("../project_config.yml")
|
||||
run_config = train.load_config("../run_configs.yml")[RUN_CONFIG_NAME]
|
||||
|
||||
# Initialize wandb
|
||||
wandb.init()
|
||||
|
||||
@@ -4,4 +4,3 @@ pytorch-lightning-bolts>=0.2.5
|
||||
wandb>=0.10.11
|
||||
PyYAML>=5.3.1
|
||||
scikit-learn>=0.23.2
|
||||
efficientnet-pytorch>=0.7.0
|
||||
Reference in new issue
Block a user