gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/test/gpu/smoke_test.go (about)

     1  // Copyright 2023 The gVisor Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // Package smoke_test tests basic GPU functionality.
    16  package smoke_test
    17  
    18  import (
    19  	"context"
    20  	"testing"
    21  
    22  	"gvisor.dev/gvisor/pkg/test/dockerutil"
    23  )
    24  
    25  func TestGPUHello(t *testing.T) {
    26  	ctx := context.Background()
    27  	c := dockerutil.MakeContainer(ctx, t)
    28  	defer c.CleanUp(ctx)
    29  
    30  	opts := dockerutil.GPURunOpts()
    31  	opts.Image = "basic/cuda-vector-add"
    32  	out, err := c.Run(ctx, opts)
    33  	if err != nil {
    34  		t.Fatalf("could not run cuda-vector-add: %v", err)
    35  	}
    36  	t.Logf("cuda-vector-add output: %s", string(out))
    37  }
    38  
    39  func TestCUDASmokeTests(t *testing.T) {
    40  	ctx := context.Background()
    41  	c := dockerutil.MakeContainer(ctx, t)
    42  	defer c.CleanUp(ctx)
    43  
    44  	opts := dockerutil.GPURunOpts()
    45  	opts.Image = "gpu/cuda-tests"
    46  	out, err := c.Run(ctx, opts, "/run_smoke.sh")
    47  	if err != nil {
    48  		t.Fatalf("could not run cuda-tests smoke tests: %v", err)
    49  	}
    50  	t.Logf("cuda-tests smoke tests output: %s", string(out))
    51  }