測試說明¶
測試(位於 fbgemm_gpu/test/
目錄中)和基準測試(位於 fbgemm_gpu/bench/
目錄中)提供了關於如何使用 FBGEMM_GPU 的良好範例。
設定 FBGEMM_GPU 測試環境¶
在從建置/安裝 FBGEMM_GPU 套件取得環境之後,需要安裝額外的套件才能正確執行測試
# !! Run inside the Conda environment !!
# From the /fbgemm_gpu/ directory
python -m pip install -r requirements.txt
執行 FBGEMM_GPU 測試¶
若要在建置/安裝 FBGEMM_GPU 套件後執行測試
# !! Run inside the Conda environment !!
# From the /fbgemm_gpu/ directory
cd test
python -m pytest -v -rsx -s -W ignore::pytest.PytestCollectionWarning split_table_batched_embeddings_test.py
python -m pytest -v -rsx -s -W ignore::pytest.PytestCollectionWarning quantize_ops_test.py
python -m pytest -v -rsx -s -W ignore::pytest.PytestCollectionWarning sparse_ops_test.py
python -m pytest -v -rsx -s -W ignore::pytest.PytestCollectionWarning split_embedding_inference_converter_test.py
使用 CUDA 變體進行測試¶
對於 FBGEMM_GPU CUDA 套件,將自動偵測 GPU 並用於測試。若要在僅限 CPU 模式的具備 GPU 功能的機器上執行測試和基準測試,必須在環境中設定 CUDA_VISIBLE_DEVICES=-1
# !! Run inside the Conda environment !!
# Enable for running in CPU-only mode (when on a GPU-capable machine)
export CUDA_VISIBLE_DEVICES=-1
# Enable for debugging failed kernel executions
export CUDA_LAUNCH_BLOCKING=1
# For operators involving NCCL, if the rpath is not set up correctly for
# libnccl.so.2, LD_LIBRARY_PATH will need to be updated.
export LD_LIBRARY_PATH="/path/to/nccl/lib:${LD_LIBRARY_PATH}"
python -m pytest -v -rsx -s -W ignore::pytest.PytestCollectionWarning split_table_batched_embeddings_test.py
使用 ROCm 變體進行測試¶
對於 ROCm 機器,需要透過在環境中設定 FBGEMM_TEST_WITH_ROCM=1
來啟用針對 ROCm GPU 的測試
# !! Run inside the Conda environment !!
# From the /fbgemm_gpu/ directory
cd test
export FBGEMM_TEST_WITH_ROCM=1
# Enable for debugging failed kernel executions
export HIP_LAUNCH_BLOCKING=1
python -m pytest -v -rsx -s -W ignore::pytest.PytestCollectionWarning split_table_batched_embeddings_test.py
執行 FBGEMM_GPU 基準測試¶
若要執行基準測試
# !! Run inside the Conda environment !!
# From the /fbgemm_gpu/ directory
cd bench
python split_table_batched_embeddings_benchmark.py uvm