# cudatest **Repository Path**: wanghuiic/cudatest ## Basic Information - **Project Name**: cudatest - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-04-02 - **Last Updated**: 2025-10-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # cudatest 以web服务的形式测试cuda ## build ``` img="cudatest:20250402" docker image rm $img docker build -t $img . ``` Dockerfile.debug 用于调试。 ``` docker build -t $img -f Dockerfile.debug . ``` ## 测试 启动服务 ```bash # docker run --rm -it $img /bin/bash * Serving Flask app 'app' * Debug mode: on WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Running on all addresses (0.0.0.0) * Running on http://127.0.0.1:8080 * Running on http://172.17.0.2:8080 Press CTRL+C to quit * Restarting with stat * Debugger is active! * Debugger PIN: 617-710-839 ``` 根据上面的信息,客户端访问, ``` # curl http://172.17.0.2:8080/cudatest

CUDA Test Result

[Vector addition of 50000 elements]
Copy input data from the host memory to the CUDA device
CUDA kernel launch with 196 blocks of 256 threads
Copy output data from the CUDA device to the host memory
Test PASSED
Done
``` 服务端后台输出, ``` 172.17.0.1 - - [02/Apr/2025 05:03:29] "GET /cudatest HTTP/1.1" 200 - ``` ## prometheus metrics 访问 ``` # curl http://172.17.0.2:8080/metrics ``` 输出举例, ``` # HELP python_gc_objects_collected_total Objects collected during gc # TYPE python_gc_objects_collected_total counter python_gc_objects_collected_total{generation="0"} 209.0 python_gc_objects_collected_total{generation="1"} 258.0 python_gc_objects_collected_total{generation="2"} 0.0 # HELP python_gc_objects_uncollectable_total Uncollectable object found during GC # TYPE python_gc_objects_uncollectable_total counter python_gc_objects_uncollectable_total{generation="0"} 0.0 python_gc_objects_uncollectable_total{generation="1"} 0.0 python_gc_objects_uncollectable_total{generation="2"} 0.0 # HELP python_gc_collections_total Number of times this generation was collected # TYPE python_gc_collections_total counter python_gc_collections_total{generation="0"} 72.0 python_gc_collections_total{generation="1"} 6.0 python_gc_collections_total{generation="2"} 0.0 # HELP python_info Python platform information # TYPE python_info gauge python_info{implementation="CPython",major="3",minor="8",patchlevel="10",version="3.8.10"} 1.0 # HELP process_virtual_memory_bytes Virtual memory size in bytes. # TYPE process_virtual_memory_bytes gauge process_virtual_memory_bytes 1.84066048e+08 # HELP process_resident_memory_bytes Resident memory size in bytes. # TYPE process_resident_memory_bytes gauge process_resident_memory_bytes 2.9302784e+07 # HELP process_start_time_seconds Start time of the process since unix epoch in seconds. # TYPE process_start_time_seconds gauge process_start_time_seconds 1.74358382193e+09 # HELP process_cpu_seconds_total Total user and system CPU time spent in seconds. # TYPE process_cpu_seconds_total counter process_cpu_seconds_total 0.88 # HELP process_open_fds Number of open file descriptors. # TYPE process_open_fds gauge process_open_fds 7.0 # HELP process_max_fds Maximum number of open file descriptors. # TYPE process_max_fds gauge process_max_fds 1.048576e+06 # HELP http_requests_total Total number of HTTP requests # TYPE http_requests_total counter http_requests_total{endpoint="cudatest",method="GET",status_code="200"} 5.0 # TYPE http_requests_created gauge http_requests_created{endpoint="cudatest",method="GET",status_code="200"} 1.743583837793063e+09 # HELP http_request_latency_seconds HTTP request processing time # TYPE http_request_latency_seconds histogram http_request_latency_seconds_bucket{endpoint="cudatest",le="0.005",method="GET"} 0.0 http_request_latency_seconds_bucket{endpoint="cudatest",le="0.01",method="GET"} 0.0 http_request_latency_seconds_bucket{endpoint="cudatest",le="0.025",method="GET"} 0.0 http_request_latency_seconds_bucket{endpoint="cudatest",le="0.05",method="GET"} 0.0 http_request_latency_seconds_bucket{endpoint="cudatest",le="0.075",method="GET"} 0.0 http_request_latency_seconds_bucket{endpoint="cudatest",le="0.1",method="GET"} 0.0 http_request_latency_seconds_bucket{endpoint="cudatest",le="0.25",method="GET"} 0.0 http_request_latency_seconds_bucket{endpoint="cudatest",le="0.5",method="GET"} 0.0 http_request_latency_seconds_bucket{endpoint="cudatest",le="0.75",method="GET"} 2.0 http_request_latency_seconds_bucket{endpoint="cudatest",le="1.0",method="GET"} 4.0 http_request_latency_seconds_bucket{endpoint="cudatest",le="2.5",method="GET"} 5.0 http_request_latency_seconds_bucket{endpoint="cudatest",le="5.0",method="GET"} 5.0 http_request_latency_seconds_bucket{endpoint="cudatest",le="7.5",method="GET"} 5.0 http_request_latency_seconds_bucket{endpoint="cudatest",le="10.0",method="GET"} 5.0 http_request_latency_seconds_bucket{endpoint="cudatest",le="+Inf",method="GET"} 5.0 http_request_latency_seconds_count{endpoint="cudatest",method="GET"} 5.0 http_request_latency_seconds_sum{endpoint="cudatest",method="GET"} 4.601513624191284 # TYPE http_request_latency_seconds_created gauge http_request_latency_seconds_created{endpoint="cudatest",method="GET"} 1.7435838377931974e+09 ``` ## mnist example ``` kubectl port-forward --address 0.0.0.0 svc/mnist-demo-svc 18888:80 ``` ``` root@mnist-demo-567bc8c8c8-snlrr:/workspace# python YStest-tensorflow-train.py --data_url /dataset/mnist.npz --train_model_out my_model --train_out out ```