반응형

CUDA 디바이스 정보를 확인해 보자.

 

helper_cuda.h
0.03MB
helper_string.h
0.01MB

 

#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include "helper_cuda.h"

#define _1MB (1024 * 1024)

int main()
{
	int ngpus;
	cudaGetDeviceCount(&ngpus);

	for (int i = 0; i < ngpus; i++) {
		cudaDeviceProp prop;
		cudaGetDeviceProperties(&prop, i);
		size_t a;
		printf("GPU %d: %s\n", i, prop.name);
		printf("\tCompute capability: %d.%d\n", prop.major, prop.minor);
		printf("\tNumber of multiprocessors: %d\n", prop.multiProcessorCount);
		printf("\tNumber of CUDA cores: %d\n", prop.multiProcessorCount * _ConvertSMVer2Cores(prop.major, prop.minor));
		printf("\tGlobal memory: %llu MB\n", prop.totalGlobalMem / _1MB);
		printf("\tShared memory per block: %llu KB\n", prop.sharedMemPerBlock / 1024);
		printf("\tRegisters per block: %d\n", prop.regsPerBlock);
		printf("\tWarp size: %d\n", prop.warpSize);
		printf("\tMax threads per block: %d\n", prop.maxThreadsPerBlock);
		printf("\tMax threads per multiprocessor: %d\n", prop.maxThreadsPerMultiProcessor);
	}

	return 0;
}

 

 

반응형
Posted by J-sean
:
반응형

마이크를 통해 입력된 음성 데이터를 스피커로 출력해 보자.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import sounddevice as sd
import numpy as np
 
def callback(indata, outdata, frames, time, status):
    volume_norm = np.linalg.norm(indata)    
    print("Volume: " + '='*(int(volume_norm)) + ' '*(79-(int(volume_norm))) + '\r', end = '')
    
    # indata를 outdata에 넣으면 마이크로 넘어온 데이터가 스피커로 출력된다.
    outdata[:] = indata
 
try:
    with sd.Stream(callback=callback):
        input("Press Enter to quit.\n\n")
except KeyboardInterrupt:
    print("exit.")
 

 

 

코드를 실행하면 마이크에 입력된 음성이 스피커로 출력된다.

 

python-sounddevice

PyAudio Examples

 

반응형
Posted by J-sean
: