큰 데이터 배열 (2.4G)을 메모리에로드하고 결과를 호스트 (~ 1.5G)에 저장 한 다음 수행 데이터를 해제하고 결과를로드하는 추력 코드가 있습니다. 디바이스에 다른 계산을 수행하고 마지막으로 초기 데이터를 다시로드합니다. 추력 코드는 다음과 같습니다 : 무료 내 정의 된 기능으로CUDA 추력 메모리 할당 문제
thrust::host_device<float> hostData;
// here is a code which loads ~2.4G of data into hostData
thrust::device_vector<float> deviceData = hostData;
thrust::host_vector<float> hostResult;
// here is a code which perform calculations on deviceData and copies the result to hostResult (~1.5G)
free<thrust::device_vector<float> >(deviceData);
thrust::device_vector<float> deviceResult = hostResult;
// here is code which performs calculations on deviceResult and store some results also on the device
free<thrust::device_vector<float> >(deviceResult);
deviceData = hostData;
그러나
template<class T> void free(T &V) {
V.clear();
V.shrink_to_fit();
size_t mem_tot;
size_t mem_free;
cudaMemGetInfo(&mem_free, &mem_tot);
std::cout << "Free memory : " << mem_free << std::endl;
}
template void free<thrust::device_vector<int> >(thrust::device_vector<int>& V);
template void free<thrust::device_vector<float> >(
thrust::device_vector<float>& V);
, 나는 "추력 :: 시스템을 얻을 :: 세부 사항 :: bad_alloc 뿐이다 '무엇을() : 표준 : : bad_alloc : 메모리 부족 "오류 cudaMemGetInfo이 시점에서 내 장치의 ~ 6G의 여유 메모리가 있기 때문에 반환하더라도 hostData 다시 deviceData로 복사하려고하면 오류가 발생했습니다. 다음은 무료 방법의 전체 출력입니다.
Free memory : 6295650304
Free memory : 6063775744
terminate called after throwing an instance of 'thrust::system::detail::bad_alloc'
what(): std::bad_alloc: out of memory
무료인데도 불구하고 메모리가 부족하다는 뜻입니다. 트러스트 벡터를위한 메모리를 해제하는 것이 올바른 방법일까요? 나는이 코드가 더 작은 크기의 데이터 (최대 1.5G)에 대해 잘 작동 함을 알아야한다.
사용중인 운영 체제, 드라이버 및 GPU는 무엇입니까? Windows Vista/7/8 인 경우 TCC 모드가 활성화되어 있습니까? – talonmies
우분투 12.04에서 CUDA 5 및 드라이버 310.40으로 GTX Titan을 사용합니다. – Namux