gpu_test.go 858 B

123456789101112131415161718192021222324252627282930313233343536
  1. package gpu
  2. import (
  3. "runtime"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. "github.com/stretchr/testify/require"
  7. )
  8. func TestBasicGetGPUInfo(t *testing.T) {
  9. info := GetGPUInfo()
  10. assert.NotEmpty(t, len(info))
  11. assert.Contains(t, "cuda rocm cpu metal", info[0].Library)
  12. if info[0].Library != "cpu" {
  13. assert.Greater(t, info[0].TotalMemory, uint64(0))
  14. assert.Greater(t, info[0].FreeMemory, uint64(0))
  15. }
  16. }
  17. func TestCPUMemInfo(t *testing.T) {
  18. info, err := GetCPUMem()
  19. require.NoError(t, err)
  20. switch runtime.GOOS {
  21. case "darwin":
  22. t.Skip("CPU memory not populated on darwin")
  23. case "linux", "windows":
  24. assert.Greater(t, info.TotalMemory, uint64(0))
  25. assert.Greater(t, info.FreeMemory, uint64(0))
  26. default:
  27. return
  28. }
  29. }
  30. // TODO - add some logic to figure out card type through other means and actually verify we got back what we expected