最近学Deep Learning感觉chatgpt写code太爽了,码工可以进历史垃圾堆了
版主: Softfist
#22 Re: 最近学Deep Learning感觉chatgpt写code太爽了,码工可以进历史垃圾堆了
大文儿比聊天狗屁通牛逼多了
你这等于是帮聊天狗屁通一步一步debug
大文儿直接帮你debug好了
LOL
你这等于是帮聊天狗屁通一步一步debug
大文儿直接帮你debug好了
LOL
LittleBear 写了: 2024年 9月 26日 19:15 1,无论你希望要什么样的神经网络,只需要大致跟chatgpt说一下,马上就可以写出来
2,然后在jupyter notebook上调试,通不过就把error message发给chatgpt,立马就告诉你哪里错了。
3,接着让chatgpt写个新版本,立马就完成了。
4,再把新版本黏贴到jupyter notebook里面,很快就调试好了。
码工真的可以进历史的垃圾堆了。呵呵
#28 Re: 最近学Deep Learning感觉chatgpt写code太爽了,码工可以进历史垃圾堆了
Yes
上次由 newday_ 在 2024年 9月 28日 00:43 修改。
沧浪之水清兮,可以濯我缨;沧浪之水浊兮,可以濯我足
#30 Re: 最近学Deep Learning感觉chatgpt写code太爽了,码工可以进历史垃圾堆了
openai快倒閉了LittleBear 写了: 2024年 9月 26日 19:15 1,无论你希望要什么样的神经网络,只需要大致跟chatgpt说一下,马上就可以写出来
2,然后在jupyter notebook上调试,通不过就把error message发给chatgpt,立马就告诉你哪里错了。
3,接着让chatgpt写个新版本,立马就完成了。
4,再把新版本黏贴到jupyter notebook里面,很快就调试好了。
码工真的可以进历史的垃圾堆了。呵呵
#32 Re: 最近学Deep Learning感觉chatgpt写code太爽了,码工可以进历史垃圾堆了
你让它写个cuda呗
LittleBear 写了: 2024年 9月 26日 19:15 1,无论你希望要什么样的神经网络,只需要大致跟chatgpt说一下,马上就可以写出来
2,然后在jupyter notebook上调试,通不过就把error message发给chatgpt,立马就告诉你哪里错了。
3,接着让chatgpt写个新版本,立马就完成了。
4,再把新版本黏贴到jupyter notebook里面,很快就调试好了。
码工真的可以进历史的垃圾堆了。呵呵
#33 Re: 最近学Deep Learning感觉chatgpt写code太爽了,码工可以进历史垃圾堆了
Certainly! Below is a simple example of a CUDA program written in **CUDA C**. The program performs a basic operation of adding two arrays (vectors) element by element on the **GPU**.
### Example: CUDA Program to Add Two Vectors
```cpp
#include <iostream>
#include <cuda_runtime.h>
// CUDA Kernel to add elements of two arrays
__global__ void vectorAdd(const int* A, const int* B, int* C, int N) {
int idx = threadIdx.x + blockIdx.x * blockDim.x;
if (idx < N) {
C[idx] = A[idx] + B[idx];
}
}
int main() {
// Number of elements in arrays
int N = 1000;
// Size of the arrays in bytes
size_t size = N * sizeof(int);
// Allocate memory on the host (CPU)
int* h_A = (int*)malloc(size);
int* h_B = (int*)malloc(size);
int* h_C = (int*)malloc(size);
// Initialize arrays on the host
for (int i = 0; i < N; ++i) {
h_A = i;
h_B = i * 2;
}
// Allocate memory on the device (GPU)
int* d_A;
int* d_B;
int* d_C;
cudaMalloc(&d_A, size);
cudaMalloc(&d_B, size);
cudaMalloc(&d_C, size);
// Copy arrays from host to device
cudaMemcpy(d_A, h_A, size, cudaMemcpyHostToDevice);
cudaMemcpy(d_B, h_B, size, cudaMemcpyHostToDevice);
// Define the number of threads and blocks
int threadsPerBlock = 256;
int blocksPerGrid = (N + threadsPerBlock - 1) / threadsPerBlock;
// Launch the CUDA kernel
vectorAdd<<<blocksPerGrid, threadsPerBlock>>>(d_A, d_B, d_C, N);
// Copy result from device to host
cudaMemcpy(h_C, d_C, size, cudaMemcpyDeviceToHost);
// Verify the result
for (int i = 0; i < N; ++i) {
if (h_C != h_A + h_B) {
std::cerr << "Error at index " << i << std::endl;
break;
}
}
// Free memory on device and host
cudaFree(d_A);
cudaFree(d_B);
cudaFree(d_C);
free(h_A);
free(h_B);
free(h_C);
std::cout << "Vector addition completed successfully!" << std::endl;
return 0;
}
```
### Explanation of the Code:
1. **CUDA Kernel Function (`vectorAdd`)**:
- This function is executed on the GPU. The `__global__` keyword indicates that the function runs on the device (GPU) and can be called from the host (CPU).
- Each thread computes one element of the result by adding corresponding elements of arrays `A` and `B` and storing the result in array `C`.
2. **Host Code**:
- The CPU initializes the arrays `A` and `B` and allocates memory for the arrays `A`, `B`, and `C` on the GPU.
- The `cudaMalloc()` function allocates memory on the GPU, and `cudaMemcpy()` transfers data between host and device memory.
- The kernel `vectorAdd<<<blocksPerGrid, threadsPerBlock>>>` is launched, with each thread handling one element of the arrays.
3. **Threads and Blocks**:
- The number of threads per block is set to 256, and the number of blocks is calculated to ensure all elements are covered.
- The `threadIdx.x` gives the index of the thread within the block, and `blockIdx.x` gives the index of the block.
4. **Memory Management**:
- After the computation is completed, the result is copied back from the GPU to the CPU, and memory is freed on both the CPU and GPU.
### How to Compile and Run the Code:
To compile and run this CUDA program, you need to have an NVIDIA GPU with CUDA installed. You can use `nvcc`, the CUDA compiler, to compile the code:
```bash
nvcc vector_add.cu -o vector_add
./vector_add
```
If everything is set up correctly, the program will output "Vector addition completed successfully!" after performing the addition on the GPU.
Let me know if you need further clarifications or modifications!
#35 Re: 最近学Deep Learning感觉chatgpt写code太爽了,码工可以进历史垃圾堆了
码农的主要责任从来不是写代码,而是判断代码正确性
而程序正确性的检查是不可计算问题,无法使用确定算法完成
而程序正确性的检查是不可计算问题,无法使用确定算法完成
LittleBear 写了: 2024年 9月 26日 19:15 1,无论你希望要什么样的神经网络,只需要大致跟chatgpt说一下,马上就可以写出来
2,然后在jupyter notebook上调试,通不过就把error message发给chatgpt,立马就告诉你哪里错了。
3,接着让chatgpt写个新版本,立马就完成了。
4,再把新版本黏贴到jupyter notebook里面,很快就调试好了。
码工真的可以进历史的垃圾堆了。呵呵
#38 Re: 最近学Deep Learning感觉chatgpt写code太爽了,码工可以进历史垃圾堆了
原来开发一款软件,是否成功时数学定理决定的?
这么多年的软件公司搞软件都是看数学定理,不是看市场反应?