Skip to content

Commit b9b580a

Browse files
committed
--made changes to the way GPU is handled
-- changed test cases to reflect the change -- changed documentation -- other bug fixes and improvements
1 parent 77cead1 commit b9b580a

32 files changed

+199
-130
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"python.pythonPath": "env\\Scripts\\python.exe",
2+
"python.pythonPath": "new_env\\Scripts\\python.exe",
33
"python.testing.unittestEnabled": false,
44
"python.testing.nosetestsEnabled": false,
55
"python.testing.pytestEnabled": false,

docs/training.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The parameters that you would set most frequently are:
88

99
- `batch_size`: int: Number of samples in each batch of training. Defaults to `64`
1010
- `max_epochs`: int: Maximum number of epochs to be run. The maximum is in case of Early Stopping where this becomes the maximum and without Early Stopping, this is the number of epochs that will be run Defaults to `10`
11-
- `gpus`: int: The index of the GPU to be used. If zero, will use CPU. Defaults to `0`
11+
- `gpus`: int: The index of the GPU to be used. -1 will make use of all available GPUs If None, will use CPU. Defaults to `None`
1212
- `load_best`: int: Flag to load the best model saved during training. This will be ignored if checkpoint saving is turned off. Defaults to True
1313

1414
### Usage Example

docs/tutorials/01-Basic_Usage.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
" auto_lr_find=True, # Runs the LRFinder to automatically derive a learning rate\n",
153153
" batch_size=1024,\n",
154154
" max_epochs=100,\n",
155-
" gpus=1, #index of the GPU to use. 0, means CPU\n",
155+
" gpus=-1, #index of the GPU to use. -1 means all available GPUs, None, means CPU\n",
156156
")\n",
157157
"optimizer_config = OptimizerConfig()\n",
158158
"\n",
@@ -593,4 +593,4 @@
593593
},
594594
"nbformat": 4,
595595
"nbformat_minor": 4
596-
}
596+
}

docs/tutorials/02-Advanced_Usage.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
"fast_dev_run: false\n",
207207
"max_epochs: 20\n",
208208
"min_epochs: 1\n",
209-
"gpus: 1\n",
209+
"gpus: -1\n",
210210
"accumulate_grad_batches: 1\n",
211211
"auto_lr_find: false\n",
212212
"check_val_every_n_epoch: 1\n",
@@ -641,7 +641,7 @@
641641
" max_epochs=epochs,\n",
642642
" early_stopping=None,\n",
643643
" accumulate_grad_batches=2,\n",
644-
" gpus=1, #index of the GPU to use. 0, means CPU\n",
644+
" gpus=-1, #index of the GPU to use. -1 means using all available GPUs. None, means CPU\n",
645645
")\n",
646646
"\n",
647647
"\n",
@@ -14480,4 +14480,4 @@
1448014480
},
1448114481
"nbformat": 4,
1448214482
"nbformat_minor": 4
14483-
}
14483+
}

docs/tutorials/03-Extracting and Using Learned Embeddings.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
" auto_lr_find=True, # Runs the LRFinder to automatically derive a learning rate\n",
202202
" batch_size=1024,\n",
203203
" max_epochs=1000,\n",
204-
" gpus=1, #index of the GPU to use. 0, means CPU\n",
204+
" gpus=-1, #index of the GPU to use. -1 means all available GPUs, None, means CPU\n",
205205
")\n",
206206
"optimizer_config = OptimizerConfig()\n",
207207
"model_config = CategoryEmbeddingModelConfig(\n",

docs/tutorials/04-Implementing New Architectures.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@
280280
" auto_lr_find=True, # Runs the LRFinder to automatically derive a learning rate\n",
281281
" batch_size=1024,\n",
282282
" max_epochs=100,\n",
283-
" gpus=1, #index of the GPU to use. 0, means CPU\n",
283+
" gpus=-1, #index of the GPU to use. -1 means all available GPUs, None, means CPU\n",
284284
")\n",
285285
"optimizer_config = OptimizerConfig()\n",
286286
"\n",
@@ -623,4 +623,4 @@
623623
},
624624
"nbformat": 4,
625625
"nbformat_minor": 4
626-
}
626+
}

docs/tutorials/05-Experiment_Tracking.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
" auto_lr_find=True, # Runs the LRFinder to automatically derive a learning rate\n",
153153
" batch_size=1024,\n",
154154
" max_epochs=100,\n",
155-
" gpus=1, #index of the GPU to use. 0, means CPU\n",
155+
" gpus=-1, #index of the GPU to use. -1 means all available GPUs, None, means CPU\n",
156156
")\n",
157157
"optimizer_config = OptimizerConfig()\n",
158158
"\n",
@@ -253,7 +253,7 @@
253253
" batch_size=64,\n",
254254
" accumulate_grad_batches=16,\n",
255255
" max_epochs=100,\n",
256-
" gpus=1, #index of the GPU to use. 0, means CPU\n",
256+
" gpus=-1, #index of the GPU to use. -1 means all available GPUs, None, means CPU\n",
257257
")\n",
258258
"optimizer_config = OptimizerConfig()\n",
259259
"\n",
@@ -357,7 +357,7 @@
357357
"# accumulate_grad_batches=16,\n",
358358
" max_epochs=100,\n",
359359
" min_epochs=10,\n",
360-
" gpus=1, #index of the GPU to use. 0, means CPU\n",
360+
" gpus=-1, #index of the GPU to use. -1 means all available GPUs, None, means CPU\n",
361361
")\n",
362362
"optimizer_config = OptimizerConfig()\n",
363363
"\n",
@@ -462,7 +462,7 @@
462462
" max_epochs=50,\n",
463463
" min_epochs=10,\n",
464464
" early_stopping=None,\n",
465-
" gpus=1, #index of the GPU to use. 0, means CPU\n",
465+
" gpus=-1, #index of the GPU to use. -1 means all available GPUs, None, means CPU\n",
466466
")\n",
467467
"optimizer_config = OptimizerConfig()\n",
468468
"\n",
@@ -569,4 +569,4 @@
569569
},
570570
"nbformat": 4,
571571
"nbformat_minor": 4
572-
}
572+
}

docs/tutorials/06-Imbalanced Classification.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
" auto_lr_find=True, # Runs the LRFinder to automatically derive a learning rate\n",
145145
" batch_size=1024,\n",
146146
" max_epochs=100,\n",
147-
" gpus=1, #index of the GPU to use. 0, means CPU\n",
147+
" gpus=-1, #index of the GPU to use. -1 means all available GPUs, None, means CPU\n",
148148
")\n",
149149
"optimizer_config = OptimizerConfig()\n",
150150
"\n",
@@ -426,4 +426,4 @@
426426
},
427427
"nbformat": 4,
428428
"nbformat_minor": 4
429-
}
429+
}

docs/tutorials/07-Probabilistic Regression with MDN.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@
267267
" batch_size=batch_size,\n",
268268
" max_epochs=epochs,\n",
269269
" early_stopping_patience = 5,\n",
270-
" gpus=1, #index of the GPU to use. 0, means CPU\n",
270+
" gpus=-1, #index of the GPU to use. -1 means all available GPUs, None, means CPU\n",
271271
")\n",
272272
"# optimizer_config = OptimizerConfig(lr_scheduler=\"OneCycleLR\", lr_scheduler_params={\"max_lr\":0.005, \"epochs\": epochs, \"steps_per_epoch\":steps_per_epoch})\n",
273273
"optimizer_config = OptimizerConfig(lr_scheduler=\"ReduceLROnPlateau\", lr_scheduler_params={\"patience\":3})\n",
@@ -611,7 +611,7 @@
611611
" batch_size=batch_size,\n",
612612
" max_epochs=epochs,\n",
613613
" early_stopping_patience = 5,\n",
614-
" gpus=1, #index of the GPU to use. 0, means CPU\n",
614+
" gpus=-1, #index of the GPU to use. -1 means all available GPUs, None, means CPU\n",
615615
")\n",
616616
"# optimizer_config = OptimizerConfig(lr_scheduler=\"OneCycleLR\", lr_scheduler_params={\"max_lr\":0.005, \"epochs\": epochs, \"steps_per_epoch\":steps_per_epoch})\n",
617617
"optimizer_config = OptimizerConfig(lr_scheduler=\"ReduceLROnPlateau\", lr_scheduler_params={\"patience\":3})\n",
@@ -856,7 +856,7 @@
856856
" max_epochs=epochs,\n",
857857
" early_stopping_patience = 5,\n",
858858
" early_stopping=None,\n",
859-
" gpus=1, #index of the GPU to use. 0, means CPU\n",
859+
" gpus=-1, #index of the GPU to use. -1 means all available GPUs, None, means CPU\n",
860860
")\n",
861861
"# optimizer_config = OptimizerConfig(lr_scheduler=\"OneCycleLR\", lr_scheduler_params={\"max_lr\":0.005, \"epochs\": epochs, \"steps_per_epoch\":steps_per_epoch})\n",
862862
"optimizer_config = OptimizerConfig(lr_scheduler=\"ReduceLROnPlateau\", lr_scheduler_params={\"patience\":3})\n",
@@ -1367,7 +1367,7 @@
13671367
" batch_size=batch_size,\n",
13681368
" max_epochs=epochs,\n",
13691369
" early_stopping_patience = 5,\n",
1370-
" gpus=1, #index of the GPU to use. 0, means CPU\n",
1370+
" gpus=-1, #index of the GPU to use. -1 means all available GPUs, None, means CPU\n",
13711371
")\n",
13721372
"# optimizer_config = OptimizerConfig(lr_scheduler=\"OneCycleLR\", lr_scheduler_params={\"max_lr\":0.005, \"epochs\": epochs, \"steps_per_epoch\":steps_per_epoch})\n",
13731373
"optimizer_config = OptimizerConfig(lr_scheduler=\"ReduceLROnPlateau\", lr_scheduler_params={\"patience\":3})\n",
@@ -1608,7 +1608,7 @@
16081608
" max_epochs=epochs,\n",
16091609
" early_stopping_patience = 5,\n",
16101610
" early_stopping=None,\n",
1611-
" gpus=1, #index of the GPU to use. 0, means CPU\n",
1611+
" gpus=-1, #index of the GPU to use. -1 means all available GPUs, None, means CPU\n",
16121612
")\n",
16131613
"# optimizer_config = OptimizerConfig(lr_scheduler=\"OneCycleLR\", lr_scheduler_params={\"max_lr\":0.005, \"epochs\": epochs, \"steps_per_epoch\":steps_per_epoch})\n",
16141614
"optimizer_config = OptimizerConfig(lr_scheduler=\"ReduceLROnPlateau\", lr_scheduler_params={\"patience\":3})\n",
@@ -2297,7 +2297,7 @@
22972297
" max_epochs=epochs,\n",
22982298
" early_stopping_patience = 5,\n",
22992299
"# early_stopping=None,\n",
2300-
" gpus=1, #index of the GPU to use. 0, means CPU\n",
2300+
" gpus=-1, #index of the GPU to use. -1 means all available GPUs, None, means CPU\n",
23012301
")\n",
23022302
"# optimizer_config = OptimizerConfig(lr_scheduler=\"OneCycleLR\", lr_scheduler_params={\"max_lr\":0.005, \"epochs\": epochs, \"steps_per_epoch\":steps_per_epoch})\n",
23032303
"optimizer_config = OptimizerConfig(lr_scheduler=\"ReduceLROnPlateau\", lr_scheduler_params={\"patience\":3})\n",
@@ -2766,4 +2766,4 @@
27662766
},
27672767
"nbformat": 4,
27682768
"nbformat_minor": 4
2769-
}
2769+
}

examples/to_test_classification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
# metrics=["f1", "accuracy"],
9898
# metrics_params=[{"num_classes": num_classes, "average": "macro"}, {}],
9999
# )
100-
trainer_config = TrainerConfig(gpus=1, fast_dev_run=False, max_epochs=5, batch_size=1024)
100+
trainer_config = TrainerConfig(gpus=-1, auto_select_gpus=True, fast_dev_run=False, max_epochs=5, batch_size=1024)
101101
experiment_config = ExperimentConfig(project_name="PyTorch Tabular Example",
102102
run_name="node_forest_cov",
103103
exp_watch="gradients",

0 commit comments

Comments
 (0)