8000 adding cuda to RegModel test_util by kevin-vitro · Pull Request #4052 · fastai/fastai · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

adding cuda to RegModel test_util #4052

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions fastai/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"""For quick testing of the training loop and Callbacks"""

# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/97_test_utils.ipynb.

# %% ../nbs/97_test_utils.ipynb 0
Expand Down Expand Up @@ -32,14 +30,16 @@ def get_data(n):

# %% ../nbs/97_test_utils.ipynb 5
class RegModel(Module):
def __init__(self): self.a,self.b = nn.Parameter(torch.randn(1)),nn.Parameter(torch.randn(1))
def __init__(self, cuda=False):
device = default_device() if cuda else None
self.a,self.b = nn.Parameter(torch.randn(1, device=device)),nn.Parameter(torch.randn(1, device=device))
def forward(self, x): return x*self.a + self.b

# %% ../nbs/97_test_utils.ipynb 6
@delegates(Learner.__init__)
def synth_learner(n_trn=10, n_val=2, cuda=False, lr=1e-3, data=None, model=None, **kwargs):
if data is None: data=synth_dbunch(n_train=n_trn,n_valid=n_val, cuda=cuda)
if model is None: model=RegModel()
if model is None: model=RegModel(cuda=cuda)
return Learner(data, model, lr=lr, loss_func=MSELossFlat(),
opt_func=partial(SGD, mom=0.9), **kwargs)

Expand Down
177 changes: 26 additions & 151 deletions nbs/97_test_utils.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@
"source": [
"#|export\n",
"class RegModel(Module):\n",
" def __init__(self): self.a,self.b = nn.Parameter(torch.randn(1)),nn.Parameter(torch.randn(1))\n",
" def __init__(self, cuda=False): \n",
" device = default_device() if cuda else None\n",
" self.a,self.b = nn.Parameter(torch.randn(1, device=device)),nn.Parameter(torch.randn(1, device=device))\n",
" def forward(self, x): return x*self.a + self.b"
]
},
Expand All @@ -85,7 +87,7 @@
"@delegates(Learner.__init__)\n",
"def synth_learner(n_trn=10, n_val=2, cuda=False, lr=1e-3, data=None, model=None, **kwargs):\n",
" if data is None: data=synth_dbunch(n_train=n_trn,n_valid=n_val, cuda=cuda)\n",
" if model is None: model=RegModel()\n",
" if model is None: model=RegModel(cuda=cuda)\n",
" return Learner(data, model, lr=lr, loss_func=MSELossFlat(),\n",
" opt_func=partial(SGD, mom=0.9), **kwargs)"
]
Expand Down Expand Up @@ -176,18 +178,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['48600', '7982']"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"nvidia_mem()"
]
Expand Down Expand Up @@ -305,71 +296,30 @@
"\n",
"```text\n",
"=== Software === \n",
"python : 3.8.5\n",
"fastai : 2.2.4\n",
"fastcore : 1.3.16\n",
"fastprogress : 0.2.7\n",
"torch : 1.7.0\n",
"nvidia driver : 460.32\n",
"torch cuda : 11.0 / is available\n",
"torch cudnn : 8003 / is enabled\n",
"python : 3.10.6\n",
"fastai : 2.7.17\n",
"fastcore : 1.7.9\n",
"fastprogress : 1.0.3\n",
"torch : 1.12.1+cpu\n",
"torch cuda : None / is **Not available** \n",
"\n",
"=== Hardware === \n",
"nvidia gpus : 2\n",
"torch devices : 2\n",
" - gpu0 : Quadro RTX 8000\n",
" - gpu1 : GeForce RTX 2070 SUPER\n",
"No GPUs available \n",
"\n",
"=== Environment === \n",
"platform : Linux-5.8.0-36-generic-x86_64-with-glibc2.10\n",
"distro : #40~20.04.1-Ubuntu SMP Wed Jan 6 10:15:55 UTC 2021\n",
"conda env : fastai\n",
"python : /home/tcapelle/miniconda3/envs/fastai/bin/python\n",
"sys.path : /home/tcapelle/Apps/fastai/nbs\n",
"/home/tcapelle/miniconda3/envs/fastai/lib/python38.zip\n",
"/home/tcapelle/miniconda3/envs/fastai/lib/python3.8\n",
"/home/tcapelle/miniconda3/envs/fastai/lib/python3.8/lib-dynload\n",
"\n",
"/home/tcapelle/miniconda3/envs/fastai/lib/python3.8/site-packages\n",
"/home/tcapelle/Apps/fastai\n",
"/home/tcapelle/Apps/nbdev\n",
"/home/tcapelle/Apps/fastcore\n",
"/home/tcapelle/SteadySun/app-suneye\n",
"/home/tcapelle/miniconda3/envs/fastai/lib/python3.8/site-packages/IPython/extensions\n",
"/home/tcapelle/.ipython\n",
"\n",
"Mon Jan 18 21:35:23 2021 \n",
"+-----------------------------------------------------------------------------+\n",
"| NVIDIA-SMI 460.32.03 Driver Version: 460.32.03 CUDA Version: 11.2 |\n",
"|-------------------------------+----------------------+----------------------+\n",
"| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\n",
"| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\n",
"| | | MIG M. |\n",
"|===============================+======================+======================|\n",
"| 0 Quadro RTX 8000 Off | 00000000:08:00.0 Off | Off |\n",
"| 33% 38C P8 11W / 260W | 12857MiB / 48600MiB | 0% Default |\n",
"| | | N/A |\n",
"+-------------------------------+----------------------+----------------------+\n",
"| 1 GeForce RTX 207... Off | 00000000:09:00.0 Off | N/A |\n",
"| 0% 45C P8 29W / 215W | 7466MiB / 7982MiB | 0% Default |\n",
"| | | N/A |\n",
"+-------------------------------+----------------------+----------------------+\n",
" \n",
"+-----------------------------------------------------------------------------+\n",
"| Processes: |\n",
"| GPU GI CI PID Type Process name GPU Memory |\n",
"| ID ID Usage |\n",
"|=============================================================================|\n",
"| 0 N/A N/A 1152 G /usr/lib/xorg/Xorg 10MiB |\n",
"| 0 N/A N/A 1345 G /usr/bin/gnome-shell 4MiB |\n",
"| 0 N/A N/A 51371 C ...a3/envs/fastai/bin/python 827MiB |\n",
"| 0 N/A N/A 52150 C ...a3/envs/fastai/bin/python 11011MiB |\n",
"| 0 N/A N/A 52914 C ...a3/envs/fastai/bin/python 1001MiB |\n",
"| 1 N/A N/A 1152 G /usr/lib/xorg/Xorg 4MiB |\n",
"| 1 N/A N/A 51371 C ...a3/envs/fastai/bin/python 6601MiB |\n",
"| 1 N/A N/A 52914 C ...a3/envs/fastai/bin/python 857MiB |\n",
"+-----------------------------------------------------------------------------+\n",
"platform : Linux-5.4.0-187-generic-x86_64-with-glibc2.35\n",
"distro : #207-Ubuntu SMP Mon Jun 10 08:16:10 UTC 2024\n",
"conda env : Unknown\n",
"python : /usr/bin/python\n",
"sys.path : /data/nbs\n",
"/usr/lib/python310.zip\n",
"/usr/lib/python3.10\n",
"/usr/lib/python3.10/lib-dynload\n",
"\n",
"/usr/local/lib/python3.10/dist-packages\n",
"/data\n",
"/usr/lib/python3/dist-packages\n",
"no supported gpus found on this system\n",
"```\n",
"\n",
"Please make sure to include opening/closing ``` when you paste into forums/github to make the reports appear formatted as code sections.\n",
Expand All @@ -396,82 +346,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Converted 00_torch_core.ipynb.\n",
"Converted 01_layers.ipynb.\n",
"Converted 01a_losses.ipynb.\n",
"Converted 02_data.load.ipynb.\n",
"Converted 03_data.core.ipynb.\n",
"Converted 04_data.external.ipynb.\n",
"Converted 05_data.transforms.ipynb.\n",
"Converted 06_data.block.ipynb.\n",
"Converted 07_vision.core.ipynb.\n",
"Converted 08_vision.data.ipynb.\n",
"Converted 09_vision.augment.ipynb.\n",
"Converted 09b_vision.utils.ipynb.\n",
"Converted 09c_vision.widgets.ipynb.\n",
"Converted 10_tutorial.pets.ipynb.\n",
"Converted 10b_tutorial.albumentations.ipynb.\n",
"Converted 11_vision.models.xresnet.ipynb.\n",
"Converted 12_optimizer.ipynb.\n",
"Converted 13_callback.core.ipynb.\n",
"Converted 13a_learner.ipynb.\n",
"Converted 13b_metrics.ipynb.\n",
"Converted 14_callback.schedule.ipynb.\n",
"Converted 14a_callback.data.ipynb.\n",
"Converted 15_callback.hook.ipynb.\n",
"Converted 15a_vision.models.unet.ipynb.\n",
"Converted 16_callback.progress.ipynb.\n",
"Converted 17_callback.tracker.ipynb.\n",
"Converted 18_callback.fp16.ipynb.\n",
"Converted 18a_callback.training.ipynb.\n",
"Converted 18b_callback.preds.ipynb.\n",
"Converted 19_callback.mixup.ipynb.\n",
"Converted 20_interpret.ipynb.\n",
"Converted 20a_distributed.ipynb.\n",
"Converted 21_vision.learner.ipynb.\n",
"Converted 22_tutorial.imagenette.ipynb.\n",
"Converted 23_tutorial.vision.ipynb.\n",
"Converted 24_tutorial.siamese.ipynb.\n",
"Converted 24_vision.gan.ipynb.\n",
"Converted 30_text.core.ipynb.\n",
"Converted 31_text.data.ipynb.\n",
"Converted 32_text.models.awdlstm.ipynb.\n",
"Converted 33_text.models.core.ipynb.\n",
"Converted 34_callback.rnn.ipynb.\n",
"Converted 35_tutorial.wikitext.ipynb.\n",
"Converted 36_text.models.qrnn.ipynb.\n",
"Converted 37_text.learner.ipynb.\n",
"Converted 38_tutorial.text.ipynb.\n",
"Converted 39_tutorial.transformers.ipynb.\n",
"Converted 40_tabular.core.ipynb.\n",
"Converted 41_tabular.data.ipynb.\n",
"Converted 42_tabular.model.ipynb.\n",
"Converted 43_tabular.learner.ipynb.\n",
"Converted 44_tutorial.tabular.ipynb.\n",
"Converted 45_collab.ipynb.\n",
"Converted 46_tutorial.collab.ipynb.\n",
"Converted 50_tutorial.datablock.ipynb.\n",
"Converted 60_medical.imaging.ipynb.\n",
"Converted 61_tutorial.medical_imaging.ipynb.\n",
"Converted 65_medical.text.ipynb.\n",
"Converted 70_callback.wandb.ipynb.\n",
"Converted 71_callback.tensorboard.ipynb.\n",
"Converted 72_callback.neptune.ipynb.\n",
"Converted 73_callback.captum.ipynb.\n",
"Converted 97_test_utils.ipynb.\n",
"Converted 99_pytorch_doc.ipynb.\n",
"Converted dev-setup.ipynb.\n",
"Converted index.ipynb.\n",
"Converted quick_start.ipynb.\n",
"Converted tutorial.ipynb.\n"
]
}
],
"outputs": [],
"source": [
"#|hide\n",
"from nbdev import *\n",
Expand All @@ -491,7 +366,7 @@
"split_at_heading": true
},
"kernelspec": {
"display_name": "python3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
}
Expand Down
Loading
0