Skip to content

Commit 1550036

Browse files
authored
Merge pull request #2131 from tkatila/gpu-tf-to-pt-demo
2 parents 791a964 + 5eadaa4 commit 1550036

File tree

5 files changed

+41
-73
lines changed

5 files changed

+41
-73
lines changed

deployments/gpu_pytorch_demo/demo.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2025 Intel Corporation. All Rights Reserved.
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+
import torch as t
16+
17+
if not t.xpu.is_available():
18+
raise Exception("No xpu available")
19+
20+
arr = t.tensor([1.0, 2.0, 3.0, 4.0]).to("xpu")
21+
22+
arr *= 2
23+
24+
print(arr)
25+
26+
cmp = t.tensor([2.0, 4.0, 6.0, 8.0]).to("xpu")
27+
28+
if not t.equal(arr, cmp):
29+
raise Exception("Not valid result:", arr)

deployments/gpu_tensorflow_test/deployment.yaml renamed to deployments/gpu_pytorch_demo/deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ spec:
66
restartPolicy: Never
77
containers:
88
- name: testcontainer
9-
image: intel/intel-extension-for-tensorflow:latest
9+
image: intel/intel-extension-for-pytorch:xpu
1010
imagePullPolicy: IfNotPresent
1111
securityContext:
1212
allowPrivilegeEscalation: false
1313
command: ["/bin/sh", "-c"]
14-
args: ["python /code/training.py"]
14+
args: ["python3 /code/demo.py"]
1515
resources:
1616
limits:
1717
gpu.intel.com/i915: 1
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
configMapGenerator:
22
- name: training-code
33
files:
4-
- training.py
4+
- demo.py
55

66
resources:
77
- deployment.yaml
88

99
images:
10-
- name: intel/intel-extension-for-tensorflow
11-
newTag: 1.2.0-gpu
10+
- name: intel/intel-extension-for-pytorch
11+
newTag: 2.8.10-xpu

deployments/gpu_tensorflow_test/training.py

Lines changed: 0 additions & 61 deletions
This file was deleted.

test/e2e/gpu/gpu.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ const (
4141
healthMgmtYaml = "deployments/gpu_plugin/overlays/health/kustomization.yaml"
4242
nfdRulesYaml = "deployments/nfd/overlays/node-feature-rules/kustomization.yaml"
4343
containerName = "testcontainer"
44-
tfKustomizationYaml = "deployments/gpu_tensorflow_test/kustomization.yaml"
45-
tfPodName = "training-pod"
44+
ptKustomizationYaml = "deployments/gpu_pytorch_demo/kustomization.yaml"
45+
ptPodName = "training-pod"
4646
)
4747

4848
func init() {
@@ -195,12 +195,12 @@ func describe() {
195195
})
196196
})
197197

198-
ginkgo.It("run a small workload on the GPU [App:tensorflow]", func(ctx context.Context) {
198+
ginkgo.It("run a small workload on the GPU [App:pytorch]", func(ctx context.Context) {
199199
createPluginAndVerifyExistence(f, ctx, vanillaPath, "gpu.intel.com/i915")
200200

201-
kustomYaml, err := utils.LocateRepoFile(tfKustomizationYaml)
201+
kustomYaml, err := utils.LocateRepoFile(ptKustomizationYaml)
202202
if err != nil {
203-
framework.Failf("unable to locate %q: %v", tfKustomizationYaml, err)
203+
framework.Failf("unable to locate %q: %v", ptKustomizationYaml, err)
204204
}
205205

206206
ginkgo.By("submitting demo deployment")
@@ -209,8 +209,8 @@ func describe() {
209209

210210
ginkgo.By("waiting the pod to finish")
211211

212-
err = e2epod.WaitForPodSuccessInNamespaceTimeout(ctx, f.ClientSet, tfPodName, f.Namespace.Name, 300*time.Second)
213-
gomega.Expect(err).To(gomega.BeNil(), utils.GetPodLogs(ctx, f, tfPodName, containerName))
212+
err = e2epod.WaitForPodSuccessInNamespaceTimeout(ctx, f.ClientSet, ptPodName, f.Namespace.Name, 300*time.Second)
213+
gomega.Expect(err).To(gomega.BeNil(), utils.GetPodLogs(ctx, f, ptPodName, containerName))
214214

215215
framework.Logf("tensorflow execution succeeded!")
216216
})

0 commit comments

Comments
 (0)