Skip to content

Commit

Permalink
Merge branch 'main' into feat/llama
Browse files Browse the repository at this point in the history
  • Loading branch information
abuccts authored Nov 27, 2024
2 parents b08f9e3 + 96f5cce commit 54c3e85
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
1 change: 1 addition & 0 deletions .azure-pipelines/ansible-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ trigger:

pool:
name: SuperBench CI
demands: ansible-agent
vmImage: ubuntu-latest

container:
Expand Down
10 changes: 7 additions & 3 deletions .azure-pipelines/cuda-unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,26 @@ trigger:

pool:
name: SuperBench CI
demands: cuda-agent
vmImage: ubuntu-latest

container:
image: nvcr.io/nvidia/pytorch:24.03-py3
options: '-v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker -v /usr/bin/sudo:/usr/bin/sudo -v /usr/lib/sudo/:/usr/lib/sudo/'
options: '--name cuda-ci -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker:ro'

steps:
- script: |
echo "##vso[task.prependpath]$HOME/.local/bin"
displayName: Export path
- script: |
docker exec -t -u root -e DEBIAN_FRONTEND=noninteractive cuda-ci bash -c \
"apt-get update -y -q && \
yes '' | apt-get install -y -q sudo && \
apt-get install -y -q \
ffmpeg libavcodec-dev libavformat-dev libavutil-dev libboost-program-options-dev libswresample-dev"
python3 -m pip install --upgrade pip setuptools==65.7
python3 -m pip install .[test,nvworker]
make postinstall
sudo DEBIAN_FRONTEND=noninteractive apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y ffmpeg libavcodec-dev libavformat-dev libavutil-dev libswresample-dev
displayName: Install dependencies
- script: |
python3 setup.py lint
Expand Down
4 changes: 4 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ coverage:
threshold: 1%
flags:
- cpu-python3.7-unit-test
- cpu-python3.8-unit-test
- cpu-python3.10-unit-test
- cuda-unit-test
- directx-unit-test
patch:
Expand All @@ -23,5 +25,7 @@ coverage:
threshold: 1%
flags:
- cpu-python3.7-unit-test
- cpu-python3.8-unit-test
- cpu-python3.10-unit-test
- cuda-unit-test
- directx-unit-test
2 changes: 2 additions & 0 deletions superbench/benchmarks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def __init__(self, name, parameters=''):
allow_abbrev=False,
formatter_class=SortedMetavarTypeHelpFormatter,
)
# Fix optionals title in Python 3.10
self._parser._optionals.title = 'optional arguments'
self._args = None
self._curr_run_index = 0
self._result = None
Expand Down
25 changes: 22 additions & 3 deletions tests/benchmarks/model_benchmarks/test_pytorch_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,35 @@ def test_pytorch_empty_cache():
# Register mnist benchmark.
BenchmarkRegistry.register_benchmark('pytorch-mnist', PytorchMNIST)

# Get initial memory reserved
init_res_memory = torch.cuda.memory_reserved()

# Test cache empty by manually calling torch.cuda.empty_cache().
parameters = '--batch_size 32 --num_warmup 8 --num_steps 64 --model_action train'
benchmark = PytorchMNIST('pytorch-mnist', parameters=parameters)

assert (benchmark)
assert (benchmark._preprocess())
assert (benchmark._benchmark())
del benchmark
assert (torch.cuda.memory_stats()['reserved_bytes.all.current'] > 0)

# Get current reserved memory after benchmark
post_bm_res_memory = torch.cuda.memory_reserved()

# Assert that memory is increased after benchmark
assert (post_bm_res_memory >= init_res_memory)

# Manually empty cache and get reserved memory
# Calling empty_cache() releases all unused cached memory from PyTorch so that those can be used by
# other GPU applications. However, the occupied GPU memory by tensors will not be freed so it can not
# increase the amount of GPU memory available for PyTorch.
# https://pytorch.org/docs/stable/notes/cuda.html#cuda-memory-management
torch.cuda.empty_cache()
assert (torch.cuda.memory_stats()['reserved_bytes.all.current'] == 0)
post_empty_cache_res_memory = torch.cuda.memory_reserved()

# Assert that some memory is released after manually empty cache. The cache is not guaranteed to be reset
# back to the init_res_memory due to some tensors not being released.
assert (post_empty_cache_res_memory <= post_bm_res_memory)

# Test automatic cache empty.
context = BenchmarkRegistry.create_benchmark_context(
Expand All @@ -268,4 +287,4 @@ def test_pytorch_empty_cache():

benchmark = BenchmarkRegistry.launch_benchmark(context)
assert (benchmark)
assert (torch.cuda.memory_stats()['reserved_bytes.all.current'] == 0)
assert (torch.cuda.memory_reserved() == post_empty_cache_res_memory)

0 comments on commit 54c3e85

Please sign in to comment.