Skip to content

Instantly share code, notes, and snippets.

@usr-ein
Created June 30, 2021 14:41
Show Gist options
  • Save usr-ein/b4f176edd990147e0a955c0c2eaa7fdb to your computer and use it in GitHub Desktop.
Save usr-ein/b4f176edd990147e0a955c0c2eaa7fdb to your computer and use it in GitHub Desktop.
Test if different DL frameworks work well with your current CUDA installation
#!/usr/bin/env python3
"""Tests PyTorch CUDA capabilities"""
import sys
import torch
def main():
"""Main function"""
print("A", sys.version)
print("B", torch.__version__)
print("C", torch.cuda.is_available())
print("D", torch.backends.cudnn.enabled)
device = torch.device("cuda")
print("E", torch.cuda.get_device_properties(device))
print("F", torch.tensor([1.0, 2.0]).cuda())
if __name__ == "__main__":
main()
#!/usr/bin/env python3
"""Module doc"""
import sys
import tensorflow as tf
import numpy as np
def main():
"""Main function"""
print(tf.config.list_physical_devices("GPU"))
print("A", sys.version)
print("B", tf.__version__)
model = tf.keras.applications.VGG16(weights='imagenet')
res = model.predict(np.random.rand(2, 224, 224, 3))
print("C", res.shape)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment