快捷方式

测试说明

测试(位于 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/test/ 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 将被自动检测并用于测试。要在具有 GPU 的机器上以仅 CPU 模式运行测试和基准测试,必须在环境中设置 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/test/ 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/bench/ directory
cd bench

python tbe_training_benchmark.py device

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取针对初学者和高级开发者的深度教程

查看教程

资源

查找开发资源并获得问题解答

查看资源