Created
May 19, 2020 02:51
-
-
Save RAMitchell/097f914da09405d9ac7d97c876c60d1f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cupy | |
import torch | |
import GPUtil | |
import xgboost as xgb | |
from torch.utils.dlpack import to_dlpack | |
from torch.utils.dlpack import from_dlpack | |
mem_before = GPUtil.getGPUs()[0].memoryUsed | |
# Create a PyTorch tensor. | |
tx1 = torch.randn(1000000, 1000).cuda() | |
print(GPUtil.getGPUs()[0].memoryUsed - mem_before) | |
# Convert it into a DLPack tensor. | |
dx = to_dlpack(tx1) | |
# Train with xgboost! | |
dmat = xgb.DeviceQuantileDMatrix(dx) | |
print(GPUtil.getGPUs()[0].memoryUsed - mem_before) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment