GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — adding more to cupy readme · amd/HPCTrainingExamples@ddff0b3

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Python/cupy/intro
    • README.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Python/cupy/intro/README.md‎

Copy file name to clipboard
+61-1Lines changed: 61 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,68 @@
1-
## Simple introduction example to CuPY for AMD GPUs
1+
## CuPY Examples
2+
3+
### Simple introduction example to CuPY for AMD GPUs
24

35
To run this example,
46

57
```
68
module load cupy
79
python intro.py
810
```
11+
12+
The output should look like the following:
13+
14+
```
15+
CuPy Array: [1 2 3 4 5]
16+
Squared CuPy Array: [ 1 4 9 16 25]
17+
NumPy Array: [5 6 7 8 9]
18+
CuPy Array from NumPy: [5 6 7 8 9]
19+
Addition Result on GPU: [ 6 8 10 12 14]
20+
Result on CPU: [ 6 8 10 12 14]
21+
```
22+
23+
What is actually happening here? What is on the GPU and what is on the CPU?
24+
Let's try and see more.
25+
26+
```
27+
export AMD_LOG_LEVEL=1
28+
python intro.py
29+
```
30+
31+
Now our output is:
32+
33+
```
34+
:1:hip_memory.cpp :3721: 1083559518128d us: Cannot get amd_mem_obj for ptr: 0x46b8a5f0
35+
CuPy Array: [1 2 3 4 5]
36+
Squared CuPy Array: [ 1 4 9 16 25]
37+
NumPy Array: [5 6 7 8 9]
38+
:1:hip_memory.cpp :3721: 1083560370823d us: Cannot get amd_mem_obj for ptr: 0x483ba890
39+
CuPy Array from NumPy: [5 6 7 8 9]
40+
Addition Result on GPU: [ 6 8 10 12 14]
41+
Result on CPU: [ 6 8 10 12 14]
42+
```
43+
44+
The warning is from the AMD logging functions and doesn't impact the run. Now let's increase the log level for the run.
45+
46+
```
47+
export AMD_LOG_LEVEL=3
48+
python intro.py
49+
```
50+
51+
Now we see lots of output that shows the hip calls and the operations on the GPU.
52+
53+
```
54+
....
55+
hipMemcpyAsync ( 0x559ea98f65f0, 0x7f4556800000, 40, hipMemcpyDeviceToHost, stream:<null> )
56+
Signal = (0x7f4d5efff280), Translated start/end = 1083534945452078 / 1083534945453358, Elapsed = 1280 ns, ticks start/end = 27091222405615 / 27091222405647, Ticks elapsed = 32
57+
Host active wait for Signal = (0x7f4d5efff200) for -1 ns
58+
Set Handler: handle(0x7f4d5efff180), timestamp(0x559eaabead90)
59+
Host active wait for Signal = (0x7f4d5efff180) for -1 ns
60+
hipMemcpyAsync: Returned hipSuccess : : duration: 5948d us
61+
hipStreamSynchronize ( stream:<null> )
62+
Handler: value(0), timestamp(0x559eaa7e7350), handle(0x7f4d5efff180)
63+
hipStreamSynchronize: Returned hipSuccess :
64+
hipSetDevice ( 0 )
65+
hipSetDevice: Returned hipSuccess :
66+
CuPy Array: [1 2 3 4 5]
67+
....
68+
```

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.