Skip to content

Commit

Permalink
Update to PyTorch 1.12 (nv-morpheus#523)
Browse files Browse the repository at this point in the history
- Update to PyTorch 1.12.
- Latest PyTorch is v1.13 but is built for CUDA 11.6/11.7. Morpheus and RAPIDS officially support up to CUDA 11.5.
- Fixes errors seen in training scripts/notebooks when using large batch sizes.
- Updates `dfencoder` from `22.09` to `22.11`
- Updated `phishing` and `root cause` inference scripts to move `cudf` imports before `torch` imports. Allows to get past this error which also occurs with PyTorch 1.10:
```
Traceback (most recent call last):
  File "root-cause-inference.py", line 33, in <module>
    import cudf
  File "/opt/conda/envs/morpheus/lib/python3.8/site-packages/cudf/__init__.py", line 5, in <module>
    validate_setup()
  File "/opt/conda/envs/morpheus/lib/python3.8/site-packages/cudf/utils/gpu_utils.py", line 18, in validate_setup
    from cuda.cudart import cudaDeviceAttr, cudaError_t
ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /opt/conda/envs/morpheus/lib/python3.8/site-packages/cuda/cudart.cpython-38-x86_64-linux-gnu.so)
````

Close nv-morpheus#491

Authors:
  - Eli Fajardo (https://github.com/efajardo-nv)

Approvers:
  - Michael Demoret (https://github.com/mdemoret-nv)

URL: nv-morpheus#523
  • Loading branch information
efajardo-nv authored Dec 15, 2022
1 parent 7635d87 commit d3c54ff
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions docker/conda/environments/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

####### Pip-only runtime dependencies (keep sorted!) #######
# Packages listed here should also be listed in setup.py
git+https://github.com/nv-morpheus/dfencoder.git@branch-22.09#egg=dfencoder
git+https://github.com/nv-morpheus/dfencoder.git@branch-23.01#egg=dfencoder
ipywidgets
jupyter-core>=4.11.2,<5.0
jupyterlab
nvidia-pyindex
pytest-benchmark>=4.0
torch==1.10.2+cu113
torch==1.12.0+cu113
tritonclient[all]==2.17.*
websockets
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ matplotlib==3.4.2
numpy==1.22.0
pandas==1.0.1
scikit_learn==1.0.2
torch==1.7.1
torch==1.12.0+cu113
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ def preprocess(self, raw_data_col, stride_len=64, max_seq_len=256):
for symbol in string.punctuation:
raw_data_col = raw_data_col.str.replace(symbol, ' ' + symbol + ' ')

byte_count = raw_data_col.str.byte_count()
max_rows_tensor = int((byte_count / 120).ceil().sum())
max_rows_tensor = len(raw_data_col) * 2

tokenizer = SubwordTokenizer(self._hashpath, do_lower_case=False)
tokenizer_output = tokenizer(raw_data_col,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
--output phishing-email-validation-output.jsonlines
"""

###########################################################################################
# cudf imports moved before torch import to avoid the following error:
# ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found
import cudf
from cudf.core.subword_tokenizer import SubwordTokenizer
###########################################################################################

import argparse
import json

Expand All @@ -29,9 +36,6 @@
import torch
from scipy.special import expit

import cudf
from cudf.core.subword_tokenizer import SubwordTokenizer


def infer(validationdata, vocab, model, output):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
--output root-cause-validation-output.jsonlines
"""

###########################################################################################
# cudf imports moved before torch import to avoid the following error:
# ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found
import cudf
from cudf.core.subword_tokenizer import SubwordTokenizer
###########################################################################################

import argparse
import json

Expand All @@ -30,9 +37,6 @@
import torch
from scipy.special import expit

import cudf
from cudf.core.subword_tokenizer import SubwordTokenizer


def infer(
validationdata,
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
install_requires=[
# Only list the packages which cannot be installed via conda here. Should mach the requirements in
# docker/conda/environments/requirements.txt
"dfencoder @ git+https://github.com/nv-morpheus/dfencoder.git@branch-22.09#egg=dfencoder",
"torch==1.10.2+cu113",
"dfencoder @ git+https://github.com/nv-morpheus/dfencoder.git@branch-23.01#egg=dfencoder",
"torch==1.12.0+cu113",
"tritonclient[all]==2.17.*", # Force to 2.17 since they require grpcio==1.41 for newer versions
],
license="Apache",
Expand Down

0 comments on commit d3c54ff

Please sign in to comment.